sha1_name: don't waste cycles in the @-parsing loop
The @-parsing loop unnecessarily checks for the sequence "@{" from (len - 2) unnecessarily. We can safely check from (len - 4). Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramkumar Ramachandra committed
May 7, 2013 at 16:55 UTC
e883a057a9da3c738dd6f6e2f1aa9498885ae1e8
1 file changed
+1
-1
sha1_name.c
+1
-1
@@ -445,7 +445,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
445
/* basic@{time or number or -number} format to query ref-log */
446
reflog_len = at = 0;
447
if (len && str[len-1] == '}') {
448
- for (at = len-2; at >= 0; at--) {
448
+ for (at = len-4; at >= 0; at--) {
449
if (str[at] == '@' && str[at+1] == '{') {
450
if (!upstream_mark(str + at, len - at)) {
451
reflog_len = (len-1) - (at+2);