]> git.notmuchmail.org Git - notmuch/blobdiff - database.cc
Fix bit-twiddling brain damage in notmuch_query_search
[notmuch] / database.cc
index 7a3019e1de0a708f31c9daba6ca0e81e9144509d..3d9672707b20a6213dc00cf4f83404da03508d5b 100644 (file)
@@ -41,25 +41,9 @@ typedef struct {
     const char *prefix;
 } prefix_t;
 
-prefix_t NORMAL_PREFIX[] = {
-    { "subject", "S" },
-    { "body", "B" },
-    { "from_name", "FN" },
-    { "to_name", "TN" },
-    { "name", "N" },
-    { "attachment", "A" }
-};
-
 prefix_t BOOLEAN_PREFIX[] = {
     { "type", "K" },
-    { "from_email", "FE" },
-    { "to_email", "TE" },
-    { "email", "E" },
-    { "date", "D" },
-    { "label", "L" },
     { "tag", "L" },
-    { "source_id", "I" },
-    { "attachment_extension", "O" },
     { "msgid", "Q" },
     { "thread", "H" },
     { "ref", "R" },
@@ -71,10 +55,6 @@ _find_prefix (const char *name)
 {
     unsigned int i;
 
-    for (i = 0; i < ARRAY_SIZE (NORMAL_PREFIX); i++)
-       if (strcmp (name, NORMAL_PREFIX[i].name) == 0)
-           return NORMAL_PREFIX[i].prefix;
-
     for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX); i++)
        if (strcmp (name, BOOLEAN_PREFIX[i].name) == 0)
            return BOOLEAN_PREFIX[i].prefix;
@@ -562,11 +542,12 @@ find_timestamp_document (notmuch_database_t *notmuch, const char *db_key,
 static char *
 timestamp_db_key (const char *key)
 {
-    if (strlen (key) + 1 > NOTMUCH_TERM_MAX) {
+    int term_len = strlen (_find_prefix ("timestamp")) + strlen (key);
+
+    if (term_len > NOTMUCH_TERM_MAX)
        return notmuch_sha1_of_string (key);
-    } else {
+    else
        return strdup (key);
-    }
 }
 
 notmuch_status_t