From aa59424812561f6d9e8c1d455d215349a90f676b Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 30 Jan 2021 13:30:18 -0400 Subject: [PATCH] lib/open: use _finish_open in n_d_create_with_config This avoids reading the configuration file twice. --- lib/open.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index cc099e51..09afd294 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -550,12 +550,16 @@ notmuch_database_create_with_config (const char *database_path, goto DONE; } - /* XXX this reads the config file twice, which is a bit wasteful */ - status = notmuch_database_open_with_config (database_path, - NOTMUCH_DATABASE_MODE_READ_WRITE, - config_path, - profile, - ¬much, &message); + if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) { + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + + status = _finish_open (notmuch, + profile, + NOTMUCH_DATABASE_MODE_READ_WRITE, + key_file, + &message); if (status) goto DONE; -- 2.43.0