You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2014/08/01 21:52:45 UTC

git commit: TAP5-2335: Spot-optimization to the NamedSet collection

Repository: tapestry-5
Updated Branches:
  refs/heads/master 7e710abee -> b0f280657


TAP5-2335: Spot-optimization to the NamedSet collection


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b0f28065
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b0f28065
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b0f28065

Branch: refs/heads/master
Commit: b0f280657b939fb1efb91cfc4c7d6e2560df19fc
Parents: 7e710ab
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Aug 1 12:52:46 2014 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Aug 1 12:52:46 2014 -0700

----------------------------------------------------------------------
 .../org/apache/tapestry5/internal/util/NamedSet.java   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b0f28065/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/NamedSet.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/NamedSet.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/NamedSet.java
index 642968f..301954c 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/NamedSet.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/NamedSet.java
@@ -1,5 +1,3 @@
-// Copyright 2011, 2012 The Apache Software Foundation
-//
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
@@ -21,6 +19,7 @@ import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.internal.util.LockSupport;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -87,7 +86,12 @@ public class NamedSet<T> extends LockSupport
     public Set<T> getValues()
     {
         Set<T> result = CollectionFactory.newSet();
+        addValues(result);
+        return result;
+    }
 
+    private void addValues(Collection<T> result)
+    {
         try
         {
             acquireReadLock();
@@ -100,7 +104,6 @@ public class NamedSet<T> extends LockSupport
                 cursor = cursor.next;
             }
 
-            return result;
         } finally
         {
             releaseReadLock();
@@ -197,7 +200,9 @@ public class NamedSet<T> extends LockSupport
      */
     public void eachValue(Worker<T> worker)
     {
-        F.flow(getValues()).each(worker);
+        Collection<T> result = CollectionFactory.newList();
+        addValues(result);
+        F.flow(result).each(worker);
     }