[
https://issues.apache.org/jira/browse/LUCENE-9960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dawid Weiss resolved LUCENE-9960.
---------------------------------
Fix Version/s: main (9.0)
Resolution: Fixed
> Avoid unnecessary top element replacement for equal elements in PriorityQueue
> -----------------------------------------------------------------------------
>
> Key: LUCENE-9960
> URL: https://issues.apache.org/jira/browse/LUCENE-9960
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Dawid Weiss
> Assignee: Dawid Weiss
> Priority: Trivial
> Fix For: main (9.0)
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Currently the priority queue implementation always replaces the top (minimum)
> element, even if it is equal to the provided argument. This seems a
> redundant. I've modified the condition and polished a few other minor things
> (unnecessary cast, size modification even if add throws AIOOB).
> Separately from the above, it is quite weird that a pq of size zero is
> allowed (and actually used!). The code is incorrect in this case, allowing
> add() to proceed and top() to return the added value. I understand it's a
> heavily used data structure but perhaps we should at least add an assertion
> to add() checking for zero-size?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]