Speeding up method searches
Per Bothner
per@bothner.com
Sun Apr 9 21:09:00 GMT 2000
Bryce McKinlay <bryce@albatross.co.nz> writes:
> Now, if the compiler could sort the methods table alphanumerically, we
> should be able to get a huge speed increase in all these places by doing
> a simple binary search.
Or if the strings were guaranteed to be interned, then the comparsion
would be very cheap - just a single pointer equality test.
There is a tradeoff here: A binary search will use fewer comparisons
than a linear search on interned strings, but the cost of each
comparison is much cheaper in the latter case, since you don't need
to look at a single character.
> Would it be possible to implement this in the compiler? Or does the
> Class::methods table somehow depend on the vtable order of methods?
Not inherently at least, I think.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list