------- Additional Comments From [hidden email] 2005-05-30 00:30 -------
Thanks for you test case Daniel, I appreciate your time in analysing this
(pardon the pun... maybe only a little... :) ).
I ran your test and got similar results, as in, with class cast or instanceof,
they were about the same, which I thought odd indeed...
Then I spotted something. You're test case uses Field.Index.NO for the
non-stringreader case. This ends up bypassing the bit of code I mentioned in
DocumentWriter (see the if() block on line 140 of DocumentWriter, for our test
the Field has to be an Indexed, tokenized field) .
I got about 10-30% slower results with class cast because using this example of
Tokenised text, the class cast does actually get thrown and caught. Yes,
results are quite broad, but the instanceof test slowest result was always
better than the faster classcast results.
Modern VM's exception creation is miles better than it used to be, but older
VM's were pretty awful. I wonder what the difference is with, say, JDK 1.3.
At the end of the day, this is only a minor performance improvement, but it can
add up when doing a LOT of documents with a lot of fields, hence I thought this
would be a worth while improvement.