From: Scott Wheeler Date: Fri, 16 Jun 2006 20:36:36 +0000 (+0000) Subject: This is much, much faster on large byte vectors and gets the current bug down X-Git-Tag: v1.5~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb1b7c8255928c3f7072786cafd76ecf8353ddbf;p=taglib This is much, much faster on large byte vectors and gets the current bug down to where it can read the tag in around 18 seconds unstead of 30 minutes. I'm going to see if I can find the other hot paths now... CCBUG:122183 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@552178 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- diff --git a/toolkit/tbytevector.cpp b/toolkit/tbytevector.cpp index 3deb8958..241a08c5 100644 --- a/toolkit/tbytevector.cpp +++ b/toolkit/tbytevector.cpp @@ -92,29 +92,15 @@ namespace TagLib { if(pattern.size() > v.size() || offset >= v.size() - 1) return -1; - // if an offset was specified, just do a recursive call on the substring - - if(offset > 0) { - - // start at the next byte aligned block - - Vector section = v.mid(offset + byteAlign - 1 - offset % byteAlign); - int match = section.find(pattern, 0, byteAlign); - return match >= 0 ? int(match + offset) : -1; - } - - // this is a simplified Boyer-Moore string searching algorithm - uchar lastOccurrence[256]; - for(uint i = 0; i < 256; ++i) lastOccurrence[i] = uchar(pattern.size()); for(uint i = 0; i < pattern.size() - 1; ++i) lastOccurrence[unsigned(pattern[i])] = uchar(pattern.size() - i - 1); - for(uint i = pattern.size() - 1; i < v.size(); i += lastOccurrence[uchar(v.at(i))]) { + for(uint i = pattern.size() - 1 + offset; i < v.size(); i += lastOccurrence[uchar(v.at(i))]) { int iBuffer = i; int iPattern = pattern.size() - 1;