sha1_name: don't waste cycles in the @-parsing loop
authorRamkumar Ramachandra <artagnon@gmail.com>
Tue, 7 May 2013 21:55:09 +0000 (16:55 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 May 2013 16:15:37 +0000 (09:15 -0700)
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>
sha1_name.c
index 6530ddd6d8c475e6cc1fa432f6314f00a7c8c415..7b59f6f4ecd7f1bf5008a1abc19245b6d0d56e3d 100644 (file)
@@ -445,7 +445,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
        /* basic@{time or number or -number} format to query ref-log */
        reflog_len = at = 0;
        if (len && str[len-1] == '}') {
-               for (at = len-2; at >= 0; at--) {
+               for (at = len-4; at >= 0; at--) {
                        if (str[at] == '@' && str[at+1] == '{') {
                                if (!upstream_mark(str + at, len - at)) {
                                        reflog_len = (len-1) - (at+2);