From 09f37253a32542839ef72174cdc14b2a61575d93 Mon Sep 17 00:00:00 2001 From: Neeraj Baid Date: Wed, 6 May 2015 16:55:49 -0700 Subject: [PATCH] Use one big array for all blobs instead of ranks. --- lib/ChunkedBlob.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/ChunkedBlob.js b/lib/ChunkedBlob.js index 81b28f3..0ceb2cc 100644 --- a/lib/ChunkedBlob.js +++ b/lib/ChunkedBlob.js @@ -10,26 +10,16 @@ export default class ChunkedBlob { constructor() { this.size = 0 - this.ranks = [[]] + this.ranks = [] } add(b) { this.size += blobLength(b) - this.ranks[0].push(b) - - for (let i = 0; i < this.ranks.length; i++) { - let rank = this.ranks[i] - if (rank.length === rankSize) { - this.ranks[i + 1] = this.ranks[i + 1] || [] - this.ranks[i + 1].push(new Blob(rank)) - this.ranks[i] = [] - } - } + this.ranks.push(b) } toBlob() { - let allRanks = [].concat(...this.ranks) - return new Blob(allRanks) + return new Blob(this.ranks) } -} +} \ No newline at end of file