[ https://issues.apache.org/jira/browse/LUCENE-9960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17346619#comment-17346619 ]
ASF subversion and git services commented on LUCENE-9960: --------------------------------------------------------- Commit ba9fee502b0c18fda312da55c6304ac8a463f509 in lucene's branch refs/heads/main from Dawid Weiss [ https://gitbox.apache.org/repos/asf?p=lucene.git;h=ba9fee5 ] LUCENE-9960: Avoid unnecessary top element replacement for equal elements in PriorityQueue. (#141) > 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 > Time Spent: 50m > 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: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org