Op Thursday 31 January 2008 18:29:12 schreef Mark Harwood (JIRA):
> 
>     [ 
> https://issues.apache.org/jira/browse/LUCENE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12564415#action_12564415
>  ] 
> 
> Mark Harwood commented on LUCENE-584:
> -------------------------------------
> 
> Hi Paul,
> Just eyeballed the code but not had a chance to patch and run it yet.
> 
> I was wondering about the return type for skipTo() after looking at these 
> types of calls:
>        if (docIdSetIterator.skipTo(i) && (docIdSetIterator.doc() == i))
> 
> You could save a method invocation in cases like this if skipTo() returned 
> the next doc id rather than a boolean.
> Returning a -1 would be the equivalent of what used to be "false". 
> Not tried benchmarking it but does this seem like something worth considering?
> 
> Cheers
> Mark

Performance is always worth consideration, but this is another
issue.

Returning -1 is not without cost either, it's a constant that needs
to be loaded on the called side and tested against on the calling side.
A returned boolean may have to be loaded and can be tested directly,
so with good inlining I'd expect it to be faster in the normal case in
which the document number is not needed immediately.
The code shown is likely from an explain() method, and not from
a next() or skipTo() implementation, and then it's not the normal case.

Less (using a boolean) is more (performance) in this case, I think, but
benchmarking may show something else.

This skipTo() is also Scorer.skipTo(), so a change there could have an even
bigger impact than a change in Filter. Have a look at the size of the take4
patch at LUCENE-584 before trying to change skipTo() at home :)

Regards,
Paul Elschot

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to