1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-04 17:47:03 +03:00

path-lookup: optimize a common strv copy operation away

Follow-up for:

https://github.com/systemd/systemd/pull/3033#discussion_r59689398
This commit is contained in:
Lennart Poettering 2016-04-20 18:20:51 +02:00
parent 3411372e35
commit 8f1e0ad415

View File

@ -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);