mirror of
https://github.com/taglib/taglib.git
synced 2025-06-03 09:08:09 -04:00
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
This commit is contained in:
parent
ebf56779f4
commit
eb1b7c8255
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user