FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 08-27-2012, 07:24 AM
Allan McRae
 
Default query_fileowner: don't append '/' if path is "/"

On 12/08/12 07:35, Andrew Gregory wrote:
> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> ---
> src/pacman/query.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/pacman/query.c b/src/pacman/query.c
> index 9afe680..d882e5a 100644
> --- a/src/pacman/query.c
> +++ b/src/pacman/query.c
> @@ -123,8 +123,10 @@ static int query_fileowner(alpm_list_t *targets)
> }
>
> /* append trailing '/' removed by realpath */
> - path[rootlen++] = '/';
> - path[rootlen] = '';
> + if(strcmp(path, "/") != 0) {

Given this is the uncommon case, can we change this to the less expensive:

if(rootlen == 1 && path[0] == '/')


> + path[rootlen++] = '/';
> + path[rootlen] = '';
> + }
>
> db_local = alpm_get_localdb(config->handle);
>
>
 
Old 08-28-2012, 04:34 AM
Andrew Gregory
 
Default query_fileowner: don't append '/' if path is "/"

On Mon, 27 Aug 2012 17:24:54 +1000
Allan McRae <allan@archlinux.org> wrote:

> On 12/08/12 07:35, Andrew Gregory wrote:
> > Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> > ---
> > src/pacman/query.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/pacman/query.c b/src/pacman/query.c
> > index 9afe680..d882e5a 100644
> > --- a/src/pacman/query.c
> > +++ b/src/pacman/query.c
> > @@ -123,8 +123,10 @@ static int query_fileowner(alpm_list_t
> > *targets) }
> >
> > /* append trailing '/' removed by realpath */
> > - path[rootlen++] = '/';
> > - path[rootlen] = '';
> > + if(strcmp(path, "/") != 0) {
>
> Given this is the uncommon case, can we change this to the less
> expensive:
>
> if(rootlen == 1 && path[0] == '/')
>
>

Sure, but we may as well make it more generalized too by just testing
for a trailing '/' with:

if(path[rootlen - 1] != '/')

> > + path[rootlen++] = '/';
> > + path[rootlen] = '';
> > + }
> >
> > db_local = alpm_get_localdb(config->handle);
> >
> >
>
>
 
Old 08-28-2012, 08:02 AM
Allan McRae
 
Default query_fileowner: don't append '/' if path is "/"

On 28/08/12 14:34, Andrew Gregory wrote:
> On Mon, 27 Aug 2012 17:24:54 +1000
> Allan McRae <allan@archlinux.org> wrote:
>
>> On 12/08/12 07:35, Andrew Gregory wrote:
>>> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
>>> ---
>>> src/pacman/query.c | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/pacman/query.c b/src/pacman/query.c
>>> index 9afe680..d882e5a 100644
>>> --- a/src/pacman/query.c
>>> +++ b/src/pacman/query.c
>>> @@ -123,8 +123,10 @@ static int query_fileowner(alpm_list_t
>>> *targets) }
>>>
>>> /* append trailing '/' removed by realpath */
>>> - path[rootlen++] = '/';
>>> - path[rootlen] = '';
>>> + if(strcmp(path, "/") != 0) {
>>
>> Given this is the uncommon case, can we change this to the less
>> expensive:
>>
>> if(rootlen == 1 && path[0] == '/')
>>
>>
>
> Sure, but we may as well make it more generalized too by just testing
> for a trailing '/' with:
>
> if(path[rootlen - 1] != '/')
>

Of course! Send it through.

Allan
 

Thread Tools




All times are GMT. The time now is 08:18 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org