Commit 4adce231 authored by Michael Droettboom's avatar Michael Droettboom

Remove redundant code

parent fff45f8b
......@@ -44,25 +44,15 @@ index 4c3f583b7..5291002a4 100644
},
createNode: function (parent, name, mode, dev, contents, mtime) {
var node = FS.createNode(parent, name, mode);
@@ -112,8 +106,17 @@ mergeInto(LibraryManager.library, {
@@ -112,6 +106,7 @@ mergeInto(LibraryManager.library, {
//console.log('LZ4 read ' + [offset, length, position]);
length = Math.min(length, stream.node.size - position);
if (length <= 0) return 0;
+
var contents = stream.node.contents;
var compressedData = contents.compressedData;
+ if (compressedData.buf === null) {
+ compressedData.buf = Module['_malloc'](LZ4.CHUNK_SIZE);
+ for (var i = 0; i < compressedData.cachedIndexes.length; i++) {
+ compressedData.cachedIndexes[i] = -1;
+ compressedData.cachedChunks[i] = Module['_malloc'](LZ4.CHUNK_SIZE);
+ assert(compressedData.cachedChunks[i] !== null)
+ }
+ }
var written = 0;
while (written < length) {
var start = contents.start + position + written; // start index in uncompressed data
@@ -122,6 +125,8 @@ mergeInto(LibraryManager.library, {
@@ -122,6 +117,8 @@ mergeInto(LibraryManager.library, {
var chunkIndex = Math.floor(start / LZ4.CHUNK_SIZE);
var compressedStart = compressedData.offsets[chunkIndex];
var compressedSize = compressedData.sizes[chunkIndex];
......@@ -71,7 +61,7 @@ index 4c3f583b7..5291002a4 100644
var currChunk;
if (compressedData.successes[chunkIndex]) {
var found = compressedData.cachedIndexes.indexOf(chunkIndex);
@@ -138,18 +143,19 @@ mergeInto(LibraryManager.library, {
@@ -138,18 +135,19 @@ mergeInto(LibraryManager.library, {
Module['decompressedChunks'] = (Module['decompressedChunks'] || 0) + 1;
}
var compressed = compressedData.data.subarray(compressedStart, compressedStart + compressedSize);
......@@ -99,7 +89,7 @@ index 4c3f583b7..5291002a4 100644
var currWritten = endInChunk - startInChunk;
written += currWritten;
}
@@ -181,4 +187,3 @@ if (LibraryManager.library['$FS__deps']) {
@@ -181,4 +179,3 @@ if (LibraryManager.library['$FS__deps']) {
warn('FS does not seem to be in use (no preloaded files etc.), LZ4 will not do anything');
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment