You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/06/17 21:09:31 UTC
git commit: JCLOUDS-457: Changed the ArrayLists in TreeHash util to
ImmutableLists.
Repository: jclouds-labs-aws
Updated Branches:
refs/heads/master f38673d83 -> 4a3fb7cbd
JCLOUDS-457: Changed the ArrayLists in TreeHash util to ImmutableLists.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/4a3fb7cb
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/4a3fb7cb
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/4a3fb7cb
Branch: refs/heads/master
Commit: 4a3fb7cbdb2b4c35647ccb5197bfe634acba3bb1
Parents: f38673d
Author: Roman C. Coedo <ro...@gmail.com>
Authored: Tue Jun 17 10:23:34 2014 +0200
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Jun 17 12:06:25 2014 -0700
----------------------------------------------------------------------
.../main/java/org/jclouds/glacier/util/TreeHash.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/4a3fb7cb/glacier/src/main/java/org/jclouds/glacier/util/TreeHash.java
----------------------------------------------------------------------
diff --git a/glacier/src/main/java/org/jclouds/glacier/util/TreeHash.java b/glacier/src/main/java/org/jclouds/glacier/util/TreeHash.java
index 07d57c1..8a97e44 100644
--- a/glacier/src/main/java/org/jclouds/glacier/util/TreeHash.java
+++ b/glacier/src/main/java/org/jclouds/glacier/util/TreeHash.java
@@ -21,17 +21,16 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.jclouds.io.Payload;
import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.Lists;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.hash.HashingInputStream;
@@ -79,7 +78,7 @@ public class TreeHash {
private static final int CHUNK_SIZE = 1024 * 1024;
private static HashCode hashList(Collection<HashCode> hashList) {
- List<HashCode> result = Lists.newArrayList();
+ Builder<HashCode> result = ImmutableList.builder();
while (hashList.size() > 1) {
//Hash pairs of values and add them to the result list.
for (Iterator<HashCode> it = hashList.iterator(); it.hasNext();) {
@@ -94,8 +93,8 @@ public class TreeHash {
result.add(hc1);
}
}
- hashList = result;
- result = Lists.newArrayList();
+ hashList = result.build();
+ result = ImmutableList.builder();
}
return hashList.iterator().next();
}
@@ -110,7 +109,7 @@ public class TreeHash {
InputStream is = null;
try {
is = checkNotNull(payload, "payload").openStream();
- ArrayList<HashCode> list = Lists.newArrayList();
+ Builder<HashCode> list = ImmutableList.builder();
HashingInputStream linearHis = new HashingInputStream(Hashing.sha256(), is);
while (true) {
HashingInputStream chunkedHis = new HashingInputStream(
@@ -122,7 +121,7 @@ public class TreeHash {
list.add(chunkedHis.hash());
}
//The result list contains exactly one element now.
- return new TreeHash(hashList(list), linearHis.hash());
+ return new TreeHash(hashList(list.build()), linearHis.hash());
} finally {
Closeables.closeQuietly(is);
}