Using shell commands versus C equivalents

youshi10 at u.washington.edu youshi10 at u.washington.edu
Wed Jun 13 17:18:13 UTC 2007




On Wed, 13 Jun 2007, Joerg Sonnenberger wrote:

> On Wed, Jun 13, 2007 at 08:26:38AM -0700, Garrett Cooper wrote:
>> Sorry -- actually I meant that (along similar lines), there was a
>> program with the following lines:
>>
>> vsystem("/bin/chmod +x %s", filename);
>>
>> and I replaced it with:
>>
>> chmod(filename, (mode_t) ( S_IXUSR | S_IXGRP | S_IXOTH ));
>
> You supposedly mean stat + chmod here, right? Trivial errors like this
> are easy to make.

Yes ><. Good catch, thanks :).

>> Next step, eliminating the linked list structure in favor or red-black
>> trees, maybe.
>
> Due to the way pkg_install works, this most likely is just adding
> complexity for no gain, it might actually slow it down.

Hmmm... the only thing is that it does the linked list traversal a number of times per dependency. I'll take a look in gdb at the size of each dependency and then confer with Kirill (my mentor) about that a bit more.

-Garrett



More information about the freebsd-hackers mailing list