[ https://issues.apache.org/jira/browse/LUCENE-5805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14575073#comment-14575073 ]
ASF subversion and git services commented on LUCENE-5805: --------------------------------------------------------- Commit 1683853 from [~mikemccand] in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1683853 ] LUCENE-5805: QueryNodeImpl.removeFromParent was doing nothing, in a costly way > QueryNodeImpl.removeFromParent does a lot of work without any effect > -------------------------------------------------------------------- > > Key: LUCENE-5805 > URL: https://issues.apache.org/jira/browse/LUCENE-5805 > Project: Lucene - Core > Issue Type: Bug > Components: modules/queryparser > Affects Versions: 4.7.2, 4.9 > Reporter: Christoph Kaser > Assignee: Michael McCandless > Attachments: LUCENE-5805.patch > > > The method _removeFromParent_ of _QueryNodeImpl_, calls _getChildren_ on the > parent and removes any occurrence of "this" from the result. > However, since a few releases, _getChildren_ returns a *copy* of the children > list, so the code has no effect (except creating a copy of the children list > which will then be thrown away). > Even worse, since _setChildren_ calls _removeFromParent_ on any previous > child, _setChildren_ now has a complexity of O(n^2) and creates a lot of > throw-away copies of the children list (for nodes with a lot of children) > {code} > public void removeFromParent() { > if (this.parent != null) { > List<QueryNode> parentChildren = this.parent.getChildren(); > Iterator<QueryNode> it = parentChildren.iterator(); > > while (it.hasNext()) { > if (it.next() == this) { > it.remove(); > } > } > > this.parent = null; > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org