Revert "speed up match finding?"
regression...
This reverts commit 71be28a195
.
This commit is contained in:
parent
71be28a195
commit
acf7a4f2ca
|
@ -794,12 +794,27 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
||||||
// search for small matches, and then find bigger ones
|
// search for small matches, and then find bigger ones
|
||||||
logD("finding possible matches");
|
logD("finding possible matches");
|
||||||
for (size_t i=0; i<stream->size(); i+=8) {
|
for (size_t i=0; i<stream->size(); i+=8) {
|
||||||
if ((i&8191)==0) logV("%d of %d",i,(int)stream->size());
|
|
||||||
for (size_t j=i+matchSize; j<stream->size(); j+=8) {
|
for (size_t j=i+matchSize; j<stream->size(); j+=8) {
|
||||||
if (memcmp(&buf[i],&buf[j],matchSize)==0) {
|
if (memcmp(&buf[i],&buf[j],matchSize)==0) {
|
||||||
BlockMatch b=BlockMatch(i,j,matchSize);
|
// store this match for later
|
||||||
|
matches.push_back(BlockMatch(i,j,matchSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logD("%d candidates",(int)matches.size());
|
||||||
|
|
||||||
|
// quit if there isn't anything
|
||||||
|
if (matches.empty()) return stream;
|
||||||
|
|
||||||
|
// search for bigger matches
|
||||||
|
for (size_t i=0; i<matches.size(); i++) {
|
||||||
|
if ((i&8191)==0) logV("match %d of %d",i,(int)matches.size());
|
||||||
|
BlockMatch& b=matches[i];
|
||||||
|
|
||||||
|
// don't do anything if this match is done
|
||||||
|
if (b.done) continue;
|
||||||
|
|
||||||
// determine match size
|
|
||||||
size_t finalLen=b.len;
|
size_t finalLen=b.len;
|
||||||
size_t origPos=b.orig+b.len;
|
size_t origPos=b.orig+b.len;
|
||||||
size_t blockPos=b.block+b.len;
|
size_t blockPos=b.block+b.len;
|
||||||
|
@ -819,25 +834,8 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
||||||
finalLen&=~7;
|
finalLen&=~7;
|
||||||
b.len=finalLen;
|
b.len=finalLen;
|
||||||
b.done=true;
|
b.done=true;
|
||||||
|
|
||||||
// if this match is bigger than the match size, change the match size
|
|
||||||
// we're only going to work on the largest matches anyway
|
|
||||||
if (finalLen>matchSize) {
|
|
||||||
logW("expand dong");
|
|
||||||
matchSize=finalLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// store this match
|
|
||||||
matches.push_back(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logD("%d candidates",(int)matches.size());
|
|
||||||
|
|
||||||
// quit if there isn't anything
|
|
||||||
if (matches.empty()) return stream;
|
|
||||||
|
|
||||||
logD("checking overlapping/bad matches");
|
logD("checking overlapping/bad matches");
|
||||||
|
|
||||||
// first stage done
|
// first stage done
|
||||||
|
|
Loading…
Reference in a new issue