From acf7a4f2cadef7c76f2f0bea25e68d9bf9b37af6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 9 Apr 2025 06:21:08 -0500 Subject: [PATCH] Revert "speed up match finding?" regression... This reverts commit 71be28a1959623956e9cd727582bb70bd97f079f. --- src/engine/cmdStreamOps.cpp | 64 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/engine/cmdStreamOps.cpp b/src/engine/cmdStreamOps.cpp index 593be78c9..61bd8c35f 100644 --- a/src/engine/cmdStreamOps.cpp +++ b/src/engine/cmdStreamOps.cpp @@ -794,41 +794,10 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock // search for small matches, and then find bigger ones logD("finding possible matches"); for (size_t i=0; isize(); i+=8) { - if ((i&8191)==0) logV("%d of %d",i,(int)stream->size()); for (size_t j=i+matchSize; jsize(); j+=8) { if (memcmp(&buf[i],&buf[j],matchSize)==0) { - BlockMatch b=BlockMatch(i,j,matchSize); - - // determine match size - size_t finalLen=b.len; - size_t origPos=b.orig+b.len; - size_t blockPos=b.block+b.len; - while (true) { - if (origPos>=stream->size() || blockPos>=stream->size()) { - break; - } - - if (buf[origPos]!=buf[blockPos]) { - break; - } - origPos++; - blockPos++; - finalLen++; - } - - finalLen&=~7; - b.len=finalLen; - 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); + // store this match for later + matches.push_back(BlockMatch(i,j,matchSize)); } } } @@ -838,6 +807,35 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector& subBlock // quit if there isn't anything if (matches.empty()) return stream; + // search for bigger matches + for (size_t i=0; i=stream->size() || blockPos>=stream->size()) { + break; + } + + if (buf[origPos]!=buf[blockPos]) { + break; + } + origPos++; + blockPos++; + finalLen++; + } + + finalLen&=~7; + b.len=finalLen; + b.done=true; + } + logD("checking overlapping/bad matches"); // first stage done