[pacman-dev] [PATCH] Optimize string comparison on 1 character compare
No need to do strcmp when we can check for direct equality, but is it worth
the optimization?
Signed-off-by: Dan McGee
On Tue, Nov 27, 2007 at 12:07:37AM -0600, Dan McGee wrote:
No need to do strcmp when we can check for direct equality, but is it worth the optimization?
I'm not sure. What does strcmp do anyway when one of its argument is only 1 char? Does it still read the other arg totally? Well, there is still the function call that is saved, but I couldn't measure any difference.
On Nov 27, 2007 2:03 AM, Xavier
On Tue, Nov 27, 2007 at 12:07:37AM -0600, Dan McGee wrote:
No need to do strcmp when we can check for direct equality, but is it worth the optimization?
I'm not sure. What does strcmp do anyway when one of its argument is only 1 char? Does it still read the other arg totally? Well, there is still the function call that is saved, but I couldn't measure any difference.
Heh- this will blow up on any file that starts with ".", so ignore my useless spam here. -Dan
On Tue, Nov 27, 2007 at 12:06:18PM -0600, Dan McGee wrote:
On Nov 27, 2007 2:03 AM, Xavier
wrote: On Tue, Nov 27, 2007 at 12:07:37AM -0600, Dan McGee wrote:
No need to do strcmp when we can check for direct equality, but is it worth the optimization?
I'm not sure. What does strcmp do anyway when one of its argument is only 1 char? Does it still read the other arg totally? Well, there is still the function call that is saved, but I couldn't measure any difference.
Heh- this will blow up on any file that starts with ".", so ignore my useless spam here.
Indeed, I noticed that, and I didn't think it was problematic. But well, I didn't like that patch much in any cases, so if you agree, then it's alright :)
participants (3)
-
Dan McGee
-
Dan McGee
-
Xavier