ruby--ruby/internal
John Hawthorn b13a7c8e36 Constant time class to class ancestor lookup
Previously when checking ancestors, we would walk all the way up the
ancestry chain checking each parent for a matching class or module.

I believe this was especially unfriendly to CPU cache since for each
step we need to check two cache lines (the class and class ext).

This check is used quite often in:
* case statements
* rescue statements
* Calling protected methods
* Class#is_a?
* Module#===
* Module#<=>

I believe it's most common to check a class against a parent class, to
this commit aims to improve that (unfortunately does not help checking
for an included Module).

This is done by storing on each class the number and an array of all
parent classes, in order (BasicObject is at index 0). Using this we can
check whether a class is a subclass of another in constant time since we
know the location to expect it in the hierarchy.
2022-02-23 19:57:42 -08:00
..
array.h
bignum.h
bits.h
class.h
cmdlineopt.h
compar.h
compile.h
compilers.h
complex.h
cont.h
dir.h
enc.h
encoding.h
enum.h
enumerator.h
error.h
eval.h
file.h
fixnum.h
gc.h
hash.h
imemo.h
inits.h
io.h
load.h
loadpath.h
math.h
missing.h
numeric.h
object.h
parse.h
proc.h
process.h
random.h
range.h
rational.h
re.h
sanitizers.h
serial.h
signal.h
static_assert.h
string.h
struct.h
symbol.h
thread.h
time.h
transcode.h
util.h
variable.h
vm.h
warnings.h