[Patch v5 06/11] lib: config list iterators

David Bremner david at tethera.net
Tue May 24 04:54:55 PDT 2016


David Bremner <david at tethera.net> writes:


> +    talloc_set_destructor (list, _notmuch_config_list_destroy);
> +    list->iterator = new Xapian::TermIterator;
> +    list->notmuch = notmuch;
> +    list->current_key = NULL;
> +    list->current_val = NULL;
> +
> +    try {
> +
> +	*list->iterator = notmuch->xapian_db->metadata_keys_begin (CONFIG_PREFIX + (prefix ? prefix : ""));
> +

minimally these two assignments to list->iterator should be right next
to each other, with a comment explaining what the heck. But I think the
following is more idiomatic

-	/* force copying onto the heap */
-	list->iterator = new Xapian::TermIterator;
-	*list->iterator = notmuch->xapian_db->metadata_keys_begin (CONFIG_PREFIX + (prefix ? prefix : ""));
+	list->iterator = new Xapian::TermIterator(notmuch->xapian_db->metadata_keys_begin
+						  (CONFIG_PREFIX + (prefix ? prefix : "")));

so that's what I've done in git



More information about the notmuch mailing list