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

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

Date: Tue, 24 May 2016 08:54:55 -0300

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


David Bremner <david@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


Thread: