[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A simple optimization for strcmp()
From: |
Soeren Sandmann |
Subject: |
Re: A simple optimization for strcmp() |
Date: |
02 May 2003 15:29:18 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Soeren Sandmann <address@hidden> writes:
> I'm not sure I'm sending this to the right address. If not, please
> tell where I should send it.
>
> The patch below has a simple optimization for strcmp() for the case
> where the two passed pointers are identical. By returning immediately
> in that case, you avoid reading both strings in from memory.
One possible problem is that if you pass in invalid pointers such as
NULL-pointers, you wouldn't segfault as before, but instead silently
return 0. This is correct since passing NULL-pointers is undefined
behavior, but maybe it's a compatibility problem anyway.
Søren