> +   private static int CHUNK_SIZE = 1024 * 1024;
> +
> +   private final Payload payload;
> +   private HashCode hash;
> +   private HashCode treeHash;
> +
> +   public TreeHasher(Payload payload) throws IOException {
> +      this.payload = payload;
> +      this.buildHashes();
> +   }
> +
> +   private static Queue<HashCode> hashQueue(Queue<HashCode> q) {
> +      //Hash pairs of values and add them to the result queue.
> +      Queue<HashCode> result = Lists.newLinkedList();
> +      while (q.size() > 1) {
> +         
> result.offer(Hashing.sha256().hashBytes(Bytes.concat(q.poll().asBytes(), 
> q.poll().asBytes())));

Avoid object creation with:

```
result.offer(Hashing.sha256().newHasher()
   .putBytes(q.poll().asBytes())
   .putBytes(q.poll().asBytes())
   .hash());

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-aws/pull/11/files#r13791772

Reply via email to