3 ms·
Erm what? Changing the class hierarchy invalidates all method caches? That sounds a bit brutal, and totally unnecessary. Can't you just have a method cache per
by perlgeek 14y ago
Erm what? Changing the class hierarchy invalidates all method caches? That sounds a bit brutal, and totally unnecessary.
Can't you just have a method cache per metaclass (or class; I'm not very familiar with how Ruby factors this stuff)? Since mixing in a role into an instances creates a new metaclass anyway, there's no need to affect instances of the original class.
- FooBarWidget 14y agoIt's because MRI's implementation is simple. They haven't bothered caching per class because it takes more code. However JRuby caches per class.
- enebo 14y agoIf you have to go and look up the method again (even ifcached) because the callsite cache is invalid then you already lost. Constantly invalidating the callsites is the real problem with this pattern.