Bug 138501 - current SVN, too slow quick search
Summary: current SVN, too slow quick search
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.4-SVN
Platform: Gentoo Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-07 15:48 UTC by Andrew Gaydenko
Modified: 2006-12-08 10:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
speed improvement (1.93 KB, patch)
2006-12-07 17:35 UTC, Stanislav Nikolov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Gaydenko 2006-12-07 15:48:26 UTC
Version:           current SVN (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages
OS:                Linux

Apparently after last changes in collection db, 'quick search' (filter above collection tree) become very slow, practically unusable for, say, ~200 albums collection.

___________
With SQLite, the search in the collection browser was case-sensitive 
with UTF-8. Patch by Stanislav Nikolov <stanley_87@mail.ru>. (BR 138482)
Comment 1 Mark Kretschmann 2006-12-07 16:11:08 UTC
Stanislav, any ideas on this one?
Comment 2 Stanislav Nikolov 2006-12-07 17:35:22 UTC
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.
Comment 3 Mark Kretschmann 2006-12-07 17:47:06 UTC
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 );
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
Comment 4 Andrew Gaydenko 2006-12-08 10:42:07 UTC
The fix works for me. Thanks!