Dawid Weiss created LUCENE-9960: ----------------------------------- Summary: 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
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: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org