You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Cao Manh Dat (JIRA)" <ji...@apache.org> on 2015/06/05 02:54:38 UTC
[jira] [Commented] (LUCENE-5805) QueryNodeImpl.removeFromParent
does a lot of work without any effect
[ https://issues.apache.org/jira/browse/LUCENE-5805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14573892#comment-14573892 ]
Cao Manh Dat commented on LUCENE-5805:
--------------------------------------
Just thumb this up for committers can see
> 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
> 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-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org