Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created April 21, 2018 01:33
Show Gist options
  • Save jgaskins/8230fbc0cd644203245be1ba40b1375b to your computer and use it in GitHub Desktop.
Save jgaskins/8230fbc0cd644203245be1ba40b1375b to your computer and use it in GitHub Desktop.
Optimized inheritance-tree walking for Opal Class#===
Opal.is_a = function(object, self) {
if(!object.$$class) { return false }
var klass = object.$$class;
var modules = klass.$$inc, index;
while(klass !== Opal.BasicObject) {
if(klass === self) { return true }
for(index = 0; index < modules.length; index++) {
if(modules[index] === self) { return true }
}
klass = klass.$$super;
modules = klass.$$inc;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment