summaryrefslogtreecommitdiff
path: root/src/shared/path-lookup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-20 18:20:51 +0200
committerLennart Poettering <lennart@poettering.net>2016-04-22 16:06:20 +0200
commit8f1e0ad415dab8f3e5d301129fe2bb25c420e66f (patch)
tree792cf0895be61825983acc6cdff1ee22a8a400d7 /src/shared/path-lookup.c
parent3411372e35fd199d46910b79b8017e9e4ffc8da8 (diff)
path-lookup: optimize a common strv copy operation away
Follow-up for: https://github.com/systemd/systemd/pull/3033#discussion_r59689398
Diffstat (limited to 'src/shared/path-lookup.c')
-rw-r--r--src/shared/path-lookup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index 80a2ea7940..ca593b6963 100644
--- 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);