projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3411372
)
path-lookup: optimize a common strv copy operation away
author
Lennart Poettering
<lennart@poettering.net>
Wed, 20 Apr 2016 16:20:51 +0000
(18:20 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 22 Apr 2016 14:06:20 +0000
(16:06 +0200)
Follow-up for:
https://github.com/systemd/systemd/pull/3033#discussion_r59689398
src/shared/path-lookup.c
patch
|
blob
|
history
diff --git
a/src/shared/path-lookup.c
b/src/shared/path-lookup.c
index
80a2ea7
..
ca593b6
100644
(file)
--- a/
src/shared/path-lookup.c
+++ b/
src/shared/path-lookup.c
@@
-586,9
+586,16
@@
int lookup_paths_init(
if (!add)
return -ENOMEM;
- r = strv_extend_strv(&paths, add, true);
- if (r < 0)
+ if (paths) {
+ r = strv_extend_strv(&paths, add, true);
+ if (r < 0)
return r;
+ } else {
+ /* Small optimization: if paths is NULL (and it usually is), we can simply assign 'add' to it,
+ * and don't have to copy anything */
+ paths = add;
+ add = NULL;
+ }
}
r = patch_root_prefix(&persistent_config, root);