From: Junio C Hamano Date: Tue, 04 Mar 2014 21:11:25 GMT Subject: [microproject idea] Message-ID: In-Reply-To: <1393921868-4382-1-git-send-email-mhagger@alum.mit.edu> Find places where we scan a string twice unnecessarily, once with strchr() and then with strlen(), e.g. const char *colon = strchr(name, ':'); int namelen = colon ? colon - name : strlen(name); and rewrite such a pattern using strchrnul() as appropriate. The above example can become const char *colon = strchrnul(name, ':'); int namelen = colon - name;