aboutsummaryrefslogtreecommitdiff
path: root/lib/database.cc
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2018-11-17 10:09:00 -0400
committerDavid Bremner <david@tethera.net>2019-05-25 07:08:20 -0300
commitb52cda90f0b05ce5055fb840e6d9dd88c09f1f83 (patch)
tree18d285f1e0d1d299e0d7a80db8bae989ff6a576c /lib/database.cc
parent575493e78534f8fd241d663b8690a22d6885e0b1 (diff)
lib: cache user prefixes in database object
This will be used to avoid needing a database access to resolve a db prefix from the corresponding UI prefix (e.g. when indexing). Arguably the setup of the separate header map does not belong here, since it is about indexing rather than querying, but we currently don't have any other indexing setup to do.
Diffstat (limited to 'lib/database.cc')
-rw-r--r--lib/database.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc
index dd1c1c7d..4f02815f 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -334,6 +334,14 @@ _setup_user_query_fields (notmuch_database_t *notmuch)
notmuch_config_list_t *list;
notmuch_status_t status;
+ notmuch->user_prefix = _notmuch_string_map_create (notmuch);
+ if (notmuch->user_prefix == NULL)
+ return NOTMUCH_STATUS_OUT_OF_MEMORY;
+
+ notmuch->user_header = _notmuch_string_map_create (notmuch);
+ if (notmuch->user_header == NULL)
+ return NOTMUCH_STATUS_OUT_OF_MEMORY;
+
status = notmuch_database_get_config_list (notmuch, CONFIG_HEADER_PREFIX, &list);
if (status)
return status;
@@ -345,6 +353,14 @@ _setup_user_query_fields (notmuch_database_t *notmuch)
const char *key = notmuch_config_list_key (list)
+ sizeof (CONFIG_HEADER_PREFIX) - 1;
+ _notmuch_string_map_append (notmuch->user_prefix,
+ key,
+ _user_prefix (notmuch, key));
+
+ _notmuch_string_map_append (notmuch->user_header,
+ key,
+ notmuch_config_list_value (list));
+
query_field.name = talloc_strdup (notmuch, key);
query_field.prefix = _user_prefix (notmuch, key);
query_field.flags = NOTMUCH_FIELD_PROBABILISTIC