summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-30 16:55:33 +0100
committerLennart Poettering <lennart@poettering.net>2018-11-30 16:55:33 +0100
commit243dd6ae1dad5165de95e960ef7c52ea5acef5e1 (patch)
treee1ae5ba54696ad68eab187869b392ccb879bbe04 /src/basic
parentb2ac2b01c8ddaabbe63bcb7168dd752f44320d86 (diff)
downloadsystemd-243dd6ae1dad5165de95e960ef7c52ea5acef5e1.tar.gz
conf-files: improve algorithm O(n²) → O(n)
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/conf-files.c5
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);