From: Timo Sirainen Date: Fri, 17 Sep 2021 13:04:00 +0000 (+0300) Subject: lib: Optimize t_strsplit_tabescaped_inplace() X-Git-Tag: 2.3.17~95 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09b2f400d2cc888c50bd72ada6efee104231d613;p=thirdparty%2Fdovecot%2Fcore.git lib: Optimize t_strsplit_tabescaped_inplace() --- diff --git a/src/lib/strescape.c b/src/lib/strescape.c index eb3fc3bcc7..973e2d0eab 100644 --- a/src/lib/strescape.c +++ b/src/lib/strescape.c @@ -308,11 +308,12 @@ const char *const *t_strsplit_tabescaped_inplace(char *data) array = t_malloc_no0(sizeof(char *) * alloc_count); array[0] = data; count = 1; - bool need_unescape = FALSE; + char *need_unescape = NULL; while ((data = strpbrk(data, "\t\001")) != NULL) { /* separator or escape char found */ if (*data == '\001') { - need_unescape = TRUE; + if (need_unescape == NULL) + need_unescape = data; data++; continue; } @@ -325,14 +326,14 @@ const char *const *t_strsplit_tabescaped_inplace(char *data) alloc_count = new_alloc_count; } *data++ = '\0'; - if (need_unescape) { - str_tabunescape(array[count-1]); - need_unescape = FALSE; + if (need_unescape != NULL) { + str_tabunescape_from(array[count-1], need_unescape); + need_unescape = NULL; } array[count++] = data; } - if (need_unescape) - str_tabunescape(array[count-1]); + if (need_unescape != NULL) + str_tabunescape_from(array[count-1], need_unescape); i_assert(count < alloc_count); array[count] = NULL;