Skip to content

Commit

Permalink
Syncing gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nmrugg committed Aug 8, 2015
1 parent 529f025 commit 6074d4a
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 150 deletions.
2 changes: 1 addition & 1 deletion src/lzma-c-min.js

Large diffs are not rendered by default.

100 changes: 52 additions & 48 deletions src/lzma-c.js
@@ -1,4 +1,4 @@
///NOTE: This file was generated by minify.js from lzma_worker.js. Do no modify.
///NOTE: This file was generated by minify.js from lzma_worker.js. Do not modify.

/// © 2015 Nathan Rugg <nmrugg@gmail.com> | MIT
/// See LICENSE for more details.
Expand Down Expand Up @@ -140,7 +140,7 @@ var LZMA = (function () {
var diff, newHigh, newLow, twoToN;
n &= 63;
if (eq(a, MIN_VALUE)) {
if (n == 0) {
if (!n) {
return a;
}
return P0_longLit;
Expand Down Expand Up @@ -242,10 +242,18 @@ var LZMA = (function () {

/** cs */
function $configure(this$static, encoder) {
$SetDictionarySize_0(encoder, 1 << this$static.ds);
encoder._numFastBytes = this$static.fb;
$SetMatchFinder(encoder, this$static.mf);
$SetLcLpPb_0(encoder, this$static.lc, this$static.lp, this$static.pb);
$SetDictionarySize_0(encoder, 1 << this$static.s);
encoder._numFastBytes = this$static.f;
$SetMatchFinder(encoder, this$static.m);

/// lc is always 3
/// lp is always 0
/// pb is always 2
encoder._numLiteralPosStateBits = 0;
encoder._numLiteralContextBits = 3;
encoder._posStateBits = 2;
///this$static._posStateMask = (1 << pb) - 1;
encoder._posStateMask = 3;
}

function $init(this$static, input, output, length_0, mode) {
Expand Down Expand Up @@ -337,7 +345,7 @@ var LZMA = (function () {
return;
while (1) {
size = -this$static._bufferOffset + this$static._blockSize - this$static._streamPos;
if (size == 0)
if (!size)
return;
numReadBytes = $read_0(this$static._stream, this$static._bufferBase, this$static._bufferOffset + this$static._streamPos, size);
if (numReadBytes == -1) {
Expand Down Expand Up @@ -765,7 +773,7 @@ var LZMA = (function () {
this$static._finished = 1;
progressPosValuePrev = this$static.nowPos64;
if (eq(this$static.nowPos64, P0_longLit)) {
if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
if (!$GetNumAvailableBytes(this$static._matchFinder)) {
$Flush(this$static, lowBits_0(this$static.nowPos64));
return;
}
Expand All @@ -779,7 +787,7 @@ var LZMA = (function () {
--this$static._additionalOffset;
this$static.nowPos64 = add(this$static.nowPos64, P1_longLit);
}
if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
if (!$GetNumAvailableBytes(this$static._matchFinder)) {
$Flush(this$static, lowBits_0(this$static.nowPos64));
return;
}
Expand All @@ -804,7 +812,7 @@ var LZMA = (function () {
$Encode_3(this$static._rangeEncoder, this$static._isMatch, complexState, 1);
if (pos < 4) {
$Encode_3(this$static._rangeEncoder, this$static._isRep, this$static._state, 1);
if (pos == 0) {
if (!pos) {
$Encode_3(this$static._rangeEncoder, this$static._isRepG0, this$static._state, 0);
if (len == 1) {
$Encode_3(this$static._rangeEncoder, this$static._isRep0Long, complexState, 0);
Expand Down Expand Up @@ -864,7 +872,7 @@ var LZMA = (function () {
}
this$static._additionalOffset -= len;
this$static.nowPos64 = add(this$static.nowPos64, fromInt(len));
if (this$static._additionalOffset == 0) {
if (!this$static._additionalOffset) {
if (this$static._matchPriceCount >= 128) {
$FillDistancesPrices(this$static);
}
Expand All @@ -873,7 +881,7 @@ var LZMA = (function () {
}
inSize[0] = this$static.nowPos64;
outSize[0] = $GetProcessedSizeAdd(this$static._rangeEncoder);
if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
if (!$GetNumAvailableBytes(this$static._matchFinder)) {
$Flush(this$static, lowBits_0(this$static.nowPos64));
return;
}
Expand All @@ -891,7 +899,7 @@ var LZMA = (function () {
if (!this$static._matchFinder) {
bt = {};
numHashBytes = 4;
if (this$static._matchFinderType == 0) {
if (!this$static._matchFinderType) {
numHashBytes = 2;
}
$SetType(bt, numHashBytes);
Expand Down Expand Up @@ -986,7 +994,9 @@ var LZMA = (function () {
function $Flush(this$static, nowPos) {
$ReleaseMFStream(this$static);
$WriteEndMarker(this$static, nowPos & this$static._posStateMask);
$FlushData(this$static._rangeEncoder);
for (var i = 0; i < 5; ++i) {
$ShiftLow(this$static._rangeEncoder);
}
}

function $GetOptimum(this$static, position) {
Expand Down Expand Up @@ -1139,7 +1149,7 @@ var LZMA = (function () {
state = this$static._optimum[posPrev].State;
}
if (posPrev == cur - 1) {
if (this$static._optimum[cur].BackPrev == 0) {
if (!this$static._optimum[cur].BackPrev) {
state = state < 7?9:11;
} else {
state = StateUpdateChar(state);
Expand All @@ -1159,7 +1169,7 @@ var LZMA = (function () {
}
opt = this$static._optimum[posPrev];
if (pos < 4) {
if (pos == 0) {
if (!pos) {
this$static.reps[0] = opt.Backs0;
this$static.reps[1] = opt.Backs1;
this$static.reps[2] = opt.Backs2;
Expand Down Expand Up @@ -1208,7 +1218,7 @@ var LZMA = (function () {
}
matchPrice = curPrice + ProbPrices[2048 - this$static._isMatch[(state << 4) + posState] >>> 2];
repMatchPrice = matchPrice + ProbPrices[2048 - this$static._isRep[state] >>> 2];
if (matchByte == currentByte && !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) {
if (matchByte == currentByte && !(nextOptimum.PosPrev < cur && !nextOptimum.BackPrev)) {
shortRepPrice = repMatchPrice + (ProbPrices[this$static._isRepG0[state] >>> 2] + ProbPrices[this$static._isRep0Long[(state << 4) + posState] >>> 2]);
if (shortRepPrice <= nextOptimum.Price) {
nextOptimum.Price = shortRepPrice;
Expand Down Expand Up @@ -1270,7 +1280,7 @@ var LZMA = (function () {
}
} while (--lenTest >= 2);
lenTest = lenTestTemp;
if (repIndex == 0) {
if (!repIndex) {
startLen = lenTest + 1;
}
if (lenTest < numAvailableBytesFull) {
Expand Down Expand Up @@ -1377,7 +1387,7 @@ var LZMA = (function () {

function $GetPureRepPrice(this$static, repIndex, state, posState) {
var price;
if (repIndex == 0) {
if (!repIndex) {
price = ProbPrices[this$static._isRepG0[state] >>> 2];
price += ProbPrices[2048 - this$static._isRep0Long[(state << 4) + posState] >>> 2];
} else {
Expand Down Expand Up @@ -1439,7 +1449,7 @@ var LZMA = (function () {
}

function $ReleaseMFStream(this$static) {
if (!!this$static._matchFinder && this$static._needReleaseMFStream) {
if (this$static._matchFinder && this$static._needReleaseMFStream) {
this$static._matchFinder._stream = null;
this$static._needReleaseMFStream = 0;
}
Expand All @@ -1456,17 +1466,10 @@ var LZMA = (function () {
this$static._distTableSize = dicLogSize * 2;
}

function $SetLcLpPb_0(this$static, lc, lp, pb) {
this$static._numLiteralPosStateBits = lp;
this$static._numLiteralContextBits = lc;
this$static._posStateBits = pb;
this$static._posStateMask = (1 << pb) - 1;
}

function $SetMatchFinder(this$static, matchFinderIndex) {
var matchFinderIndexPrev = this$static._matchFinderType;
this$static._matchFinderType = matchFinderIndex;
if (!!this$static._matchFinder && matchFinderIndexPrev != this$static._matchFinderType) {
if (this$static._matchFinder && matchFinderIndexPrev != this$static._matchFinderType) {
this$static._dictionarySizePrev = -1;
this$static._matchFinder = null;
}
Expand Down Expand Up @@ -1781,15 +1784,15 @@ var LZMA = (function () {
function $Encode_3(this$static, probs, index, symbol) {
var newBound, prob = probs[index];
newBound = (this$static.Range >>> 11) * prob;
if (symbol == 0) {
if (!symbol) {
this$static.Range = newBound;
probs[index] = prob + (2048 - prob >>> 5) << 16 >> 16;
} else {
this$static.Low = add(this$static.Low, and(fromInt(newBound), [4294967295, 0]));
this$static.Range -= newBound;
probs[index] = prob - (prob >>> 5) << 16 >> 16;
}
if ((this$static.Range & -16777216) == 0) {
if (!(this$static.Range & -16777216)) {
this$static.Range <<= 8;
$ShiftLow(this$static);
}
Expand All @@ -1801,19 +1804,13 @@ var LZMA = (function () {
if ((v >>> i & 1) == 1) {
this$static.Low = add(this$static.Low, fromInt(this$static.Range));
}
if ((this$static.Range & -16777216) == 0) {
if (!(this$static.Range & -16777216)) {
this$static.Range <<= 8;
$ShiftLow(this$static);
}
}
}

function $FlushData(this$static) {
for (var i = 0; i < 5; ++i) {
$ShiftLow(this$static);
}
}

function $GetProcessedSizeAdd(this$static) {
return add(add(fromInt(this$static._cacheSize), this$static._position), [4, 0]);
}
Expand Down Expand Up @@ -1861,7 +1858,7 @@ var LZMA = (function () {
ch = chars[i];
if (ch >= 1 && ch <= 127) {
++elen;
} else if (ch == 0 || ch >= 128 && ch <= 2047) {
} else if (!ch || ch >= 128 && ch <= 2047) {
elen += 2;
} else {
elen += 3;
Expand All @@ -1873,7 +1870,7 @@ var LZMA = (function () {
ch = chars[i];
if (ch >= 1 && ch <= 127) {
data[elen++] = ch << 24 >> 24;
} else if (ch == 0 || ch >= 128 && ch <= 2047) {
} else if (!ch || ch >= 128 && ch <= 2047) {
data[elen++] = (192 | ch >> 6 & 31) << 24 >> 24;
data[elen++] = (128 | ch & 63) << 24 >> 24;
} else {
Expand Down Expand Up @@ -1952,16 +1949,23 @@ var LZMA = (function () {

/** cs */
var get_mode_obj = (function () {
/// s is dictionarySize
/// f is fb
/// m is matchFinder
///NOTE: Because some values are always the same, they have been removed.
/// lc is always 3
/// lp is always 0
/// pb is always 2
var modes = [
{ds: 16, fb: 64, mf: 0, lc: 3, lp: 0, pb: 2},
{ds: 20, fb: 64, mf: 0, lc: 3, lp: 0, pb: 2},
{ds: 19, fb: 64, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 20, fb: 64, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 21, fb: 128, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 22, fb: 128, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 23, fb: 128, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 24, fb: 255, mf: 1, lc: 3, lp: 0, pb: 2},
{ds: 25, fb: 255, mf: 1, lc: 3, lp: 0, pb: 2}
{s: 16, f: 64, m: 0},
{s: 20, f: 64, m: 0},
{s: 19, f: 64, m: 1},
{s: 20, f: 64, m: 1},
{s: 21, f: 128, m: 1},
{s: 22, f: 128, m: 1},
{s: 23, f: 128, m: 1},
{s: 24, f: 255, m: 1},
{s: 25, f: 255, m: 1}
];

return function (mode) {
Expand Down

0 comments on commit 6074d4a

Please sign in to comment.