Skip to content

Commit 5914ace

Browse files
committed
fixed Tornado
1 parent 640b550 commit 5914ace

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

tornado/MatchFinder.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1070,10 +1070,10 @@ struct LazyMatching
10701070

10711071
// Extend match at p+1 one char backward if it's better than match at p
10721072
if (nextlen>=MINLEN && nextq[-1]==*p &&
1073-
(nextlen+1 >= prevlen && nextdist < prevdist ||
1074-
nextlen+1 == prevlen + 1 && !ChangePair(prevdist, nextdist) ||
1075-
nextlen+1 > prevlen + 1 ||
1076-
nextlen+1 + 1 >= prevlen && prevlen >= MINLEN && ChangePair(nextdist, prevdist)))
1073+
((nextlen+1 >= prevlen && nextdist < prevdist) ||
1074+
(nextlen+1 == prevlen + 1 && !ChangePair(prevdist, nextdist)) ||
1075+
(nextlen+1 > prevlen + 1) ||
1076+
(nextlen+1 + 1 >= prevlen && prevlen >= MINLEN && ChangePair(nextdist, prevdist))))
10771077
{
10781078
debug (printf ("Extending %d:%d -> %d:%d\n", nextlen, nextq-p, nextlen+1, nextq-1-p));
10791079
prevlen = nextlen+1;
@@ -1082,10 +1082,10 @@ struct LazyMatching
10821082
}
10831083

10841084
// Truncate current match if match at next position will be better (LZMA's algorithm)
1085-
if (nextlen >= prevlen && nextdist < prevdist/4 ||
1086-
nextlen == prevlen + 1 && !ChangePair(prevdist, nextdist) ||
1087-
nextlen > prevlen + 1 ||
1088-
nextlen + 1 >= prevlen && prevlen >= MINLEN && ChangePair(nextdist, prevdist))
1085+
if ((nextlen >= prevlen && nextdist < prevdist/4) ||
1086+
(nextlen == prevlen + 1 && !ChangePair(prevdist, nextdist)) ||
1087+
(nextlen > prevlen + 1) ||
1088+
(nextlen + 1 >= prevlen && prevlen >= MINLEN && ChangePair(nextdist, prevdist)))
10891089
{
10901090
return MINLEN-1;
10911091
} else {

tornado/Tornado.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const int table_dist=256*1024, table_shift=128;
9494
#define MAX_HASHED_BYTES 600
9595

9696

97-
// Îêðóãëèì ðàçìåð õåøà ñ ó÷¸òîì hash_row_width
97+
// Îêðóãëèì ðàçìåð õåøà ñ ó÷¸òîì hash_row_width
9898
uint round_to_nearest_hashsize (LongMemSize hashsize, uint hash_row_width)
9999
{return mymin (round_to_nearest_power_of(mymin(hashsize,2*gb-1) / hash_row_width, 2) * hash_row_width, 2*gb-1);}
100100

@@ -444,7 +444,7 @@ int tor_compress (PackMethod &m, CALLBACK_FUNC *callback, void *auxdata, void *b
444444
}
445445
#else
446446
// -1..-5(-6)
447-
if (m.encoding_method==BYTECODER && m.hash_row_width==1 && m.hash3==0 && m.match_finder==NON_CACHING_MF && m.match_parser==GREEDY ||
447+
if ((m.encoding_method==BYTECODER && m.hash_row_width==1 && m.hash3==0 && m.match_finder==NON_CACHING_MF && m.match_parser==GREEDY) ||
448448
m.encoding_method==STORING ) {
449449
return tor_compress0 <MatchFinder1, LZ77_ByteCoder> (m, callback, auxdata, buf, bytes_to_compress);
450450
} else if (m.encoding_method==BITCODER && m.hash_row_width==1 && m.hash3==0 && m.match_finder==NON_CACHING_MF && m.match_parser==GREEDY ) {

tornado/tor_test.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ int ReadWriteCallback (const char *what, void *buf, int size, void *r_)
6666
// Print final compression statistics
6767
return FREEARC_OK;
6868

69-
} else {
70-
return FREEARC_ERRCODE_NOT_IMPLEMENTED;
7169
}
70+
71+
return FREEARC_ERRCODE_NOT_IMPLEMENTED;
7272
}
7373

7474

@@ -101,8 +101,7 @@ uint32_t tor_compress(uint8_t method, uint8_t* inbuf, uint32_t inlen, uint8_t* o
101101
else
102102
m = std_Tornado_method[method];
103103

104-
if (r.inlen >= 0)
105-
m.buffer = mymin (m.buffer, r.inlen+LOOKAHEAD*2);
104+
m.buffer = mymin (m.buffer, r.inlen+LOOKAHEAD*2);
106105
int result = tor_compress (m, ReadWriteCallback, &r, NULL, -1);
107106
return r.outpos;
108107
}

0 commit comments

Comments
 (0)