Thread (1 message) 1 message, 1 author, 2019-03-19

Re: [PATCH 2/3] midx: verify: group objects by packfile to speed up object verification

From: Junio C Hamano <hidden>
Date: 2019-03-19 04:08:55

Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
quoted
quoted
+	if (a->pack_int_id < b->pack_int_id)
+		return -1;
+	if (a->pack_int_id > b->pack_int_id)
+		return 1;
+
+	return 0;
+}
...
succinct subtraction idiom of e.g. (in this case):

     return b->pack_int_id - a->pack_int_id;
...
On 43+M objects, your version is a hair faster, so I might
as well take it instead.
Cool!
Yup, following a well-known short idiom lets readers' eyes coast
over without forcing them to make sure the two if statements have
comparison going in the right direction and return the constant with
the right sign, etc.  Even if the idiomatic version weren't faster,
it is worth using it.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help