Thread (234 messages) 234 messages, 5 authors, 2017-04-07

Re: [PATCH v6 11/27] refs.c: introduce get_main_ref_store()

From: Michael Haggerty <hidden>
Date: 2017-03-19 20:38:29

On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote:
quoted hunk ↗ jump to hunk
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 refs.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/refs.c b/refs.c
index e7606716dd..2637353b72 100644
--- a/refs.c
+++ b/refs.c
@@ -1456,15 +1456,23 @@ static struct ref_store *ref_store_init(const char *submodule)
 	return refs;
 }
 
+static struct ref_store *get_main_ref_store(void)
+{
+	struct ref_store *refs;
+
+	if (main_ref_store)
+		return main_ref_store;
+
+	refs = ref_store_init(NULL);
+	return refs;
+}
+
I still [1] think that `refs` here is an unnecessary temporary variable.
And even after your "kill register_ref_store" patch I think it is
superfluous and the function could look like

static struct ref_store *get_main_ref_store(void)
{
	if (!main_ref_store)
		main_ref_store = ref_store_init(NULL);

	return main_ref_store;
}
[...]
Michael

[1]
http://public-inbox.org/git/0bef1e49-e96b-1666-9b88-f4262c2aeeba@alum.mit.edu/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help