Just a quick note so that I don't forget it.

Not sure how method lookup is implemented, but it occured to me that a
simple optimization might speedup lookup.  This is not a big deal when
inline caching is implemented, but nevertheless something worth considering.

i.e. given a call "o.foo(args)", normally, you might fetch C = o.class, and
then fetch C.method table and compare "foo" with the method names in some
order.

1. Maintain the method table as a sorted array of method names and do a
binary search (taking care to keep the table sorted)
2. Create a trie of method names specifically for method lookup.  This trie,
if it implements collapsing of single-character chains (a -> t -> t -> r ->
.. -> e to "attribute") to prefix strings, can give you the method you want
fairly quickly with at most 2 full-string comparisons, and usually much
faster than that.

Not sure this will give you much performance benefit, but using a trie for
method lookup is a fairly easy optimization.

Subbu.

Reply via email to