[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r33148 - in trunk/subversion: include include/private libsvn_fs libsvn_subr

From: Greg Stein <gstein_at_gmail.com>
Date: Wed, 17 Sep 2008 22:29:27 -0400

Agreed. I optimized this function and the backpath variant in r33154.

On Sep 17, 2008, at 21:20, "C. Michael Pilato" <cmpilato_at_collab.net>
wrote:

> Greg Stein wrote:
>> On Wed, Sep 17, 2008 at 2:41 PM, <danielsh_at_tigris.org> wrote:
>>> ...
>>> +++ trunk/subversion/libsvn_subr/path.c Wed Sep 17 14:41:28
>>> 2008 (r33148)
>>> @@ -842,6 +842,26 @@ svn_path_is_single_path_component(const
>>>
>>>
>>> svn_boolean_t
>>> +svn_path_is_dotpath_present(const char *path)
>>> +{
>>> + int len = strlen(path);
>>> +
>>> + if (! strcmp(path, "."))
>>> + return TRUE;
>>> +
>>> + if (! strncmp(path, "./", 2))
>>> + return TRUE;
>>> +
>>> + if (strstr(path, "/./") != NULL)
>>> + return TRUE;
>>> +
>>> + if (path[len - 2] == '/' && path[len - 1] == '.')
>>> + return TRUE;
>>
>> if len==1, then the above statement will choke. i.e. pass "a"
>>
>> I'd suggest changing the first two tests to something like:
>>
>> if (len == 1)
>> {
>> return path[0] == '.';
>> }
>> if (path[0] == '.' && path[1] == '/')
>> return TRUE;
>> ... rest of function
>
> How about delaying that strlen() as long as possible, too:
>
> int len;
>
> if (path[0] != '\0' && path[1] == '\0')
> return path[0] == '.';
>
> if (path[0] == '.' && path[1] == '/')
> return TRUE;
>
> if (strstr(path, "/./") != NULL)
> return TRUE;
>
> len = strlen(path);
> if (path[len - 2] == '/' && path[len - 1] == '.')
> return TRUE;
>
>
> --
> C. Michael Pilato <cmpilato_at_collab.net>
> CollabNet <> www.collab.net <> Distributed Development On
> Demand
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-09-18 04:29:58 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.