You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/02/20 21:47:53 UTC

svn commit: r1570347 - /commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java

Author: oheger
Date: Thu Feb 20 20:47:53 2014
New Revision: 1570347

URL: http://svn.apache.org/r1570347
Log:
ModelTransaction now uses a visitor when removing nodes from the parent mapping.

The iteration loop for traversing the nodes hierarchy has been replaced by a
call to NodeTreeWalker.walkBFS().

Modified:
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java?rev=1570347&r1=1570346&r2=1570347&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java (original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/ModelTransaction.java Thu Feb 20 20:47:53 2014
@@ -344,20 +344,17 @@ class ModelTransaction
      */
     private void removeNodesFromParentAndReplacementMapping(ImmutableNode root)
     {
-        List<ImmutableNode> pendingNodes = new LinkedList<ImmutableNode>();
-        pendingNodes.add(root);
-
-        while (!pendingNodes.isEmpty())
-        {
-            ImmutableNode node = pendingNodes.remove(0);
-            parentMapping.remove(node);
-            removeNodeFromReplacementMapping(node);
-            for (ImmutableNode c : node.getChildren())
-            {
-                pendingNodes.add(c);
-            }
-        }
-
+        NodeTreeWalker.INSTANCE.walkBFS(root,
+                new ConfigurationNodeVisitorAdapter<ImmutableNode>()
+                {
+                    @Override
+                    public void visitBeforeChildren(ImmutableNode node,
+                            NodeHandler<ImmutableNode> handler)
+                    {
+                        parentMapping.remove(node);
+                        removeNodeFromReplacementMapping(node);
+                    }
+                }, model);
     }
 
     /**