RFR-8008118
Christos Zoulas
christos at zoulas.com
Thu Mar 28 19:10:27 UTC 2013
On Mar 28, 11:12am, martinrb at google.com (Martin Buchholz) wrote:
-- Subject: Re: RFR-8008118
| My apologies for unrelenting perfectionism - I noticed that we can:
| - colocate the pathv and path in one malloc'ed chunk
| - can discard xstrdup
| - can iterate through path with only one char* pointer.
|
| Making this code even cleaner, more concise and efficient.
- for (i = 0; i < count; i++, p++) {
- pathv[i] = ((*p == ':') || (*p == '\0')) ? "." : p;
- while (! ((*p == ':') || (*p == '\0')))
- p++;
- *p = '\0';
- }
- pathv[count] = NULL;
+ for (i = 0; (pathv[i] = strsep(&p, ":")) != NULL; i++)
+ if (!pathv[i][0])
+ pathv[i] = ".";
christos
More information about the core-libs-dev
mailing list