Bug 794631 - Don't add useless WHERE clauses to empty filter queries. r=lucasr
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 26 Sep 2012 14:27:06 -0700
changeset 108310 550c5ac80046e7d378b201f53cd043546846ca00
parent 108309 3d81919584ff2fbebb0a22cdb316dbd6b22b2e9e
child 108311 cc666da08e23ac1cedeb1fdc2759946cc2fc636d
push id23552
push userryanvm@gmail.com
push dateFri, 28 Sep 2012 03:05:08 +0000
treeherdermozilla-central@2d96ee8d9dd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs794631
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 794631 - Don't add useless WHERE clauses to empty filter queries. r=lucasr
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -19,16 +19,17 @@ import android.content.ContentValues;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.database.CursorWrapper;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.provider.Browser;
+import android.text.TextUtils;
 import android.util.Log;
 
 import java.io.ByteArrayOutputStream;
 import java.util.Collection;
 import java.util.HashMap;
 
 public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
     // Calculate these once, at initialization. isLoggable is too expensive to
@@ -133,23 +134,25 @@ public class LocalBrowserDB implements B
 
     private Cursor filterAllSites(ContentResolver cr, String[] projection, CharSequence constraint,
             int limit, CharSequence urlFilter) {
         String selection = "";
         String[] selectionArgs = null;
 
         // The combined history/bookmarks selection queries for sites with a url or title containing
         // the constraint string(s), treating space-separated words as separate constraints
-        String[] constraintWords = constraint.toString().split(" ");
-        for (int i = 0; i < constraintWords.length; i++) {
-            selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " +
-                                                                  Combined.TITLE + " LIKE ?)");
-            String constraintWord =  "%" + constraintWords[i] + "%";
-            selectionArgs = DBUtils.appendSelectionArgs(selectionArgs,
-                new String[] { constraintWord, constraintWord });
+        if (!TextUtils.isEmpty(constraint)) {
+          String[] constraintWords = constraint.toString().split(" ");
+          for (int i = 0; i < constraintWords.length; i++) {
+              selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " +
+                                                                    Combined.TITLE + " LIKE ?)");
+              String constraintWord =  "%" + constraintWords[i] + "%";
+              selectionArgs = DBUtils.appendSelectionArgs(selectionArgs,
+                  new String[] { constraintWord, constraintWord });
+          }
         }
 
         if (urlFilter != null) {
             selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " NOT LIKE ?)");
             selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, new String[] { urlFilter.toString() });
         }
 
         // Our version of frecency is computed by scaling the number of visits by a multiplier