[jboss-cvs] JBossAS SVN: r84497 - projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 20 02:56:34 EST 2009
Author: alesj
Date: 2009-02-20 02:56:34 -0500 (Fri, 20 Feb 2009)
New Revision: 84497
Modified:
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/TreeStructureCache.java
Log:
Optimize new node creation a bit, #2.
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/TreeStructureCache.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/TreeStructureCache.java 2009-02-20 07:52:17 UTC (rev 84496)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/TreeStructureCache.java 2009-02-20 07:56:34 UTC (rev 84497)
@@ -71,10 +71,7 @@
{
Node<T> node = getNode(pathName);
if (node == null)
- {
- initializeNode(pathName);
- node = getNode(pathName);
- }
+ node = initializeNode(pathName);
T previous = node.getValue();
node.setValue(value);
@@ -139,8 +136,9 @@
* Initialize node for pathName param.
*
* @param pathName the path name
+ * @return initialized node
*/
- protected synchronized void initializeNode(String pathName)
+ protected synchronized Node<T> initializeNode(String pathName)
{
List<String> tokens = PathTokenizer.getTokens(pathName);
Node<T> node = root;
@@ -163,6 +161,7 @@
node = child;
}
}
+ return node;
}
/**
@@ -256,15 +255,15 @@
*
* @param node the child node
*/
- private synchronized void addChild(Node<U> node)
+ private void addChild(Node<U> node)
{
if (children == null)
children = new HashMap<String, Node<U>>();
- if (names == null)
- names = new HashSet<String>();
children.put(node.getName(), node);
- names.add(node.getFullName());
+
+ if (names != null)
+ names.add(node.getFullName());
}
/**
@@ -274,15 +273,17 @@
*/
public synchronized void removeChild(Node<U> node)
{
- if (children == null || names == null)
+ if (children == null)
return;
children.remove(node.getName());
- names.remove(node.getFullName());
+ if (names != null)
+ names.remove(node.getFullName());
+
if (children.isEmpty())
children = null;
- if (names.isEmpty())
+ if (names != null && names.isEmpty())
names = null;
}
@@ -312,9 +313,20 @@
*
* @return the children names
*/
- public Set<String> getChildrenNames()
+ public synchronized Set<String> getChildrenNames()
{
- return (names != null) ? names : Collections.<String>emptySet();
+ if (children == null)
+ return Collections.emptySet();
+
+ if (names == null)
+ {
+ names = new HashSet<String>();
+ for (Node<U> child : children.values())
+ {
+ names.add(child.getFullName());
+ }
+ }
+ return names;
}
/**
More information about the jboss-cvs-commits
mailing list