Summary: | current SVN, too slow quick search | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Andrew Gaydenko <a> |
Component: | general | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | stanley_87 |
Priority: | NOR | ||
Version: | 1.4-SVN | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | speed improvement |
Description
Andrew Gaydenko
2006-12-07 15:48:26 UTC
Stanislav, any ideas on this one? Created attachment 18832 [details]
speed improvement
Yes, I guess the previos itreration of the patch was a bit slowish. I think
this brings it in much better form. Please test.
SVN commit 611322 by markey: Possible fix for collection search performance issue. BUG: 138501 M +11 -12 collectiondb.cpp --- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #611321:611322 @@ -8,6 +8,7 @@ // (c) 2006 Jonas Hurrelmann <j@outpo.st> // (c) 2006 Shane King <kde@dontletsstart.com> // (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com> +// (c) 2006 Stanislav Nikolov <valsinats@gmail.com> // See COPYING file for licensing information. #define DEBUG_PREFIX "CollectionDB" @@ -6200,20 +6201,18 @@ QString pattern = QString::fromUtf8( (const char*)zA ); QString text = QString::fromUtf8( (const char*)zB ); - pattern = QRegExp::escape( pattern ); + int begin = pattern.startsWith( "%" ), end = pattern.endsWith( "%" ); + pattern = pattern.mid( 1, pattern.length() - 2 ); + if( argc == 3 ) // The function is given an escape character. In likeCondition() it defaults to '/' + pattern.replace( "/%", "%" ).replace( "/_", "_" ).replace( "//", "/" ); - if ( pattern.startsWith("%") ) pattern = ".*" + pattern.mid(1); - if ( pattern.endsWith("%") ) pattern = pattern.left( pattern.length() - 1 ) + ".*"; + int result = 0; + if ( begin && end ) result = ( text.find( pattern, 0, 0 ) != -1); + else if ( begin ) result = text.startsWith( pattern, 0 ); + else if ( end ) result = text.endsWith( pattern, 0 ); + else result = ( text.lower() == pattern.lower() ); - if( argc == 3 ) { - const unsigned char *zEsc = sqlite3_value_text( argv[2] ); - QChar escape = QString::fromUtf8( (const char*)zEsc ).at( 0 ); - pattern.replace( escape + '%', "%" ).replace( escape + '_', "_" ).replace( escape + '/', "/" ); - } - - const QRegExp rx( pattern, 0 /* case-sensitive */, 0 /* simple wildcards */ ); - - sqlite3_result_int( context, rx.search( text ) != -1 ); + sqlite3_result_int( context, result ); } ////////////////////////////////////////////////////////////////////////////////////////// The fix works for me. Thanks! |