Re: [PHP4BETA] cvs: php4 /ext/session/ session.c
| From: | Sascha Schumann | Date: | Mon, 15 May 2000 16:32:20 +0000 |
| Subject: | Re: [PHP4BETA] cvs: php4 /ext/session/ session.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-15058@lists.php.net to get a copy of this message | ||
> strchr() should be the exception to the rule where mem_* functions are
> faster than str_*.
strchr: "compare every byte with C and '\0'. Stop at '\0'."
memchr: "compare every byte with C. Stop when the counter is zero."
That means strchr has to perform twice as many comparisons as
memchr. The "maintaining a counter" in memchr is usually only a
decrement and a conditional jump, so the cost of doing it is
minimal, especially if you perform multiple comparisons with C in
one pass as the glibc implementation does.
- Sascha