You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Yann Ylavic <yl...@gmail.com> on 2015/11/20 23:17:56 UTC

Re: svn commit: r1715401 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/util.c

On Fri, Nov 20, 2015 at 7:49 PM,  <ji...@apache.org> wrote:
> Author: jim
> Date: Fri Nov 20 18:49:38 2015
> New Revision: 1715401
>
> URL: http://svn.apache.org/viewvc?rev=1715401&view=rev
> Log:
> Provide our own impl of str[n]casecmp()
>
> This simply provides it. Next step is to change all uses of
> str[n]casecmp to ap_str[n]casecmp and *then* remove those silly
> logic paths where we check the 1st char of a string before
> we do the strcasecmp (since this is no longer expensive).
>
> Modified:
[]
>     httpd/httpd/trunk/server/util.c
[]
> +AP_DECLARE(int) ap_strncasecmp(const char *s1, const char *s2, apr_size_t n)
> +{
> +    const unsigned char *ps1 = (const unsigned char *) s1;
> +    const unsigned char *ps2 = (const unsigned char *) s2;
> +    if (n) {
> +        do {
> +            if (ucharmap[*ps1] != ucharmap[*ps2++]) {
> +                return (ucharmap[*ps1] - ucharmap[*--ps2]);
> +            }
> +            if (*ps1++ == '\0') {
> +                /* we know both end here */
> +                return (0);
> +            }
> +        } while (!--n);

while (--n) probably.

> +    }
> +    return (0);
> +}
>
>

Re: svn commit: r1715401 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/util.c

Posted by Yann Ylavic <yl...@gmail.com>.
On Sat, Nov 21, 2015 at 2:54 PM, Jim Jagielski <ji...@jagunet.com> wrote:
> I thought about that, but we don't have many do-whiles :)

Fair enough :)

>
> But whatever people would prefer is fine w/ me...

You convinced me.

Re: svn commit: r1715401 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/util.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
I thought about that, but we don't have many do-whiles :)

But whatever people would prefer is fine w/ me...

> On Nov 20, 2015, at 5:29 PM, Yann Ylavic <yl...@gmail.com> wrote:
> 
> Alternatively, a single/simpler while (n--){} would work too.
> 
> 
> On Fri, Nov 20, 2015 at 11:17 PM, Yann Ylavic <yl...@gmail.com> wrote:
>> On Fri, Nov 20, 2015 at 7:49 PM,  <ji...@apache.org> wrote:
>>> Author: jim
>>> Date: Fri Nov 20 18:49:38 2015
>>> New Revision: 1715401
>>> 
>>> URL: http://svn.apache.org/viewvc?rev=1715401&view=rev
>>> Log:
>>> Provide our own impl of str[n]casecmp()
>>> 
>>> This simply provides it. Next step is to change all uses of
>>> str[n]casecmp to ap_str[n]casecmp and *then* remove those silly
>>> logic paths where we check the 1st char of a string before
>>> we do the strcasecmp (since this is no longer expensive).
>>> 
>>> Modified:
>> []
>>>    httpd/httpd/trunk/server/util.c
>> []
>>> +AP_DECLARE(int) ap_strncasecmp(const char *s1, const char *s2, apr_size_t n)
>>> +{
>>> +    const unsigned char *ps1 = (const unsigned char *) s1;
>>> +    const unsigned char *ps2 = (const unsigned char *) s2;
>>> +    if (n) {
>>> +        do {
>>> +            if (ucharmap[*ps1] != ucharmap[*ps2++]) {
>>> +                return (ucharmap[*ps1] - ucharmap[*--ps2]);
>>> +            }
>>> +            if (*ps1++ == '\0') {
>>> +                /* we know both end here */
>>> +                return (0);
>>> +            }
>>> +        } while (!--n);
>> 
>> while (--n) probably.
>> 
>>> +    }
>>> +    return (0);
>>> +}
>>> 
>>> 


Re: svn commit: r1715401 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/util.c

Posted by Yann Ylavic <yl...@gmail.com>.
Alternatively, a single/simpler while (n--){} would work too.


On Fri, Nov 20, 2015 at 11:17 PM, Yann Ylavic <yl...@gmail.com> wrote:
> On Fri, Nov 20, 2015 at 7:49 PM,  <ji...@apache.org> wrote:
>> Author: jim
>> Date: Fri Nov 20 18:49:38 2015
>> New Revision: 1715401
>>
>> URL: http://svn.apache.org/viewvc?rev=1715401&view=rev
>> Log:
>> Provide our own impl of str[n]casecmp()
>>
>> This simply provides it. Next step is to change all uses of
>> str[n]casecmp to ap_str[n]casecmp and *then* remove those silly
>> logic paths where we check the 1st char of a string before
>> we do the strcasecmp (since this is no longer expensive).
>>
>> Modified:
> []
>>     httpd/httpd/trunk/server/util.c
> []
>> +AP_DECLARE(int) ap_strncasecmp(const char *s1, const char *s2, apr_size_t n)
>> +{
>> +    const unsigned char *ps1 = (const unsigned char *) s1;
>> +    const unsigned char *ps2 = (const unsigned char *) s2;
>> +    if (n) {
>> +        do {
>> +            if (ucharmap[*ps1] != ucharmap[*ps2++]) {
>> +                return (ucharmap[*ps1] - ucharmap[*--ps2]);
>> +            }
>> +            if (*ps1++ == '\0') {
>> +                /* we know both end here */
>> +                return (0);
>> +            }
>> +        } while (!--n);
>
> while (--n) probably.
>
>> +    }
>> +    return (0);
>> +}
>>
>>