mirror of
https://github.com/taglib/taglib.git
synced 2025-06-03 09:08:09 -04:00
A couple more optimizations for splitting vectors. One of them makes search
faster in the simple case (no need for Boyer-Moore for a one-character search) and append a null vector rather than instantiating a new one when we find empty fields. This gets the reading time down to 6 seconds here for the reported bug, which still isn't great, but it's starting to get close to acceptable. I'll see if I can get it a little tighter... BUG:122183 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@552196 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
eb1b7c8255
commit
e83f93b2c0
@ -92,6 +92,18 @@ namespace TagLib {
|
||||
if(pattern.size() > v.size() || offset >= v.size() - 1)
|
||||
return -1;
|
||||
|
||||
// Let's go ahead and special case a pattern of size one since that's common
|
||||
// and easy to make fast.
|
||||
|
||||
if(pattern.size() == 1) {
|
||||
char p = pattern[0];
|
||||
for(uint i = offset; i < v.size(); i++) {
|
||||
if(v[i] == p && i % byteAlign == 0)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uchar lastOccurrence[256];
|
||||
|
||||
for(uint i = 0; i < 256; ++i)
|
||||
|
@ -48,7 +48,11 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt
|
||||
offset != -1 && (max == 0 || max > int(l.size()) + 1);
|
||||
offset = v.find(pattern, offset + pattern.size(), byteAlign))
|
||||
{
|
||||
l.append(v.mid(previousOffset, offset - previousOffset));
|
||||
if(offset - previousOffset > 1)
|
||||
l.append(v.mid(previousOffset, offset - previousOffset));
|
||||
else
|
||||
l.append(ByteVector::null);
|
||||
|
||||
previousOffset = offset + pattern.size();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user