diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-30 16:55:33 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-30 16:55:33 +0100 |
commit | 243dd6ae1dad5165de95e960ef7c52ea5acef5e1 (patch) | |
tree | e1ae5ba54696ad68eab187869b392ccb879bbe04 /src/basic | |
parent | b2ac2b01c8ddaabbe63bcb7168dd752f44320d86 (diff) | |
download | systemd-243dd6ae1dad5165de95e960ef7c52ea5acef5e1.tar.gz |
conf-files: improve algorithm O(n²) → O(n)
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/conf-files.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 7b44ae277d..6320674fb5 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -189,11 +189,12 @@ int conf_files_insert(char ***strv, const char *root, char **dirs, const char *p * - do nothing if our new entry matches the existing entry, * - replace the existing entry if our new entry has higher priority. */ - size_t i; + size_t i, n; char *t; int r; - for (i = 0; i < strv_length(*strv); i++) { + n = strv_length(*strv); + for (i = 0; i < n; i++) { int c; c = base_cmp((char* const*) *strv + i, (char* const*) &path); |