cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject cassandra git commit: reduce list allocations/resizes in loop
Date Fri, 30 Sep 2016 04:46:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 1be5cc0db -> 56e01770b


reduce list allocations/resizes in loop


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/56e01770
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/56e01770
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/56e01770

Branch: refs/heads/trunk
Commit: 56e01770bf556f3cfde84539da880235243cabef
Parents: 1be5cc0
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Fri Sep 30 00:46:06 2016 -0400
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Fri Sep 30 00:46:06 2016 -0400

----------------------------------------------------------------------
 .../index/sasi/utils/RangeIntersectionIterator.java         | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/56e01770/src/java/org/apache/cassandra/index/sasi/utils/RangeIntersectionIterator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/index/sasi/utils/RangeIntersectionIterator.java
b/src/java/org/apache/cassandra/index/sasi/utils/RangeIntersectionIterator.java
index 02d9527..7babf04 100644
--- a/src/java/org/apache/cassandra/index/sasi/utils/RangeIntersectionIterator.java
+++ b/src/java/org/apache/cassandra/index/sasi/utils/RangeIntersectionIterator.java
@@ -124,6 +124,8 @@ public class RangeIntersectionIterator
 
         protected D computeNext()
         {
+            List<RangeIterator<K, D>> processed = null;
+
             while (!ranges.isEmpty())
             {
                 RangeIterator<K, D> head = ranges.poll();
@@ -139,7 +141,8 @@ public class RangeIntersectionIterator
                     return endOfData();
                 }
 
-                List<RangeIterator<K, D>> processed = new ArrayList<>();
+                if (processed == null)
+                    processed = new ArrayList<>();
 
                 boolean intersectsAll = true, exhausted = false;
                 while (!ranges.isEmpty())
@@ -180,8 +183,8 @@ public class RangeIntersectionIterator
 
                 ranges.add(head);
 
-                for (RangeIterator<K, D> range : processed)
-                    ranges.add(range);
+                ranges.addAll(processed);
+                processed.clear();
 
                 if (exhausted)
                     return endOfData();


Mime
View raw message