This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: Speeding up method searches
- To: Bryce McKinlay <bryce at albatross dot co dot nz>
- Subject: Re: Speeding up method searches
- From: Per Bothner <per at bothner dot com>
- Date: 09 Apr 2000 21:05:29 -0700
- Cc: java-discuss at sourceware dot cygnus dot com
- References: <38F14C1E.CBA3055D@albatross.co.nz>
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/