diff options
author | Christian Kamm <mail@ckamm.de> | 2015-08-24 12:09:34 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2015-08-24 16:08:06 +0300 |
commit | 07ca0be3c58d4e8ed8137d9ab11fbddc82607cf8 (patch) | |
tree | 523d9c8484c82f3561ddfc8171a54003bdf07ff5 /csync/src/std/c_string.c | |
parent | e71cca128d5e7730c41d354209670bcd98f0018e (diff) |
csync_excluded: Another speedup #3638
Build a list of path components outside of the exclude pattern loop.
Diffstat (limited to 'csync/src/std/c_string.c')
-rw-r--r-- | csync/src/std/c_string.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/csync/src/std/c_string.c b/csync/src/std/c_string.c index e248f6c7c..e21d4374e 100644 --- a/csync/src/std/c_string.c +++ b/csync/src/std/c_string.c @@ -215,6 +215,25 @@ int c_strlist_add(c_strlist_t *strlist, const char *string) { return 0; } +int c_strlist_add_grow(c_strlist_t **strlist, const char *string) { + if (*strlist == NULL) { + *strlist = c_strlist_new(32); + if (*strlist == NULL) { + return -1; + } + } + + if ((*strlist)->count == (*strlist)->size) { + c_strlist_t *list = c_strlist_expand(*strlist, 2 * (*strlist)->size); + if (list == NULL) { + return -1; + } + *strlist = list; + } + + return c_strlist_add(*strlist, string); +} + void c_strlist_clear(c_strlist_t *strlist) { size_t i = 0; |