From: Junio C Hamano Date: Tue, 12 Mar 2013 20:59:40 GMT Subject: Re: [PATCH v2 3/6] match_basename: use strncmp instead of strcmp Message-ID: <7v7glc72rn.fsf@alter.siamese.dyndns.org> In-Reply-To: Duy Nguyen writes: > glibc's C strncmp version does 4-byte comparison at a time when n >=4, > then fall back to 1-byte for the rest. I don't know if it's faster > than a plain always 1-byte comparison though. There's also the hand > written assembly version that compares n from 1..16, not exactly sure > how this version works yet. It sounds to me more like "a very popular implementation of strcmp/strncmp pair found to have more optimized strncmp than strcmp". While that may be a good reason to justify this patch, I do not think it justifies this: >> strncmp is provided length information which could be taken advantage >> by the underlying implementation. After all, strcmp() could also be optimized to fetch word-at-a-time while being careful about not overstepping the page boundary.