From 4ad9738b4ddcfe593a9e6849d730e84488f1a758 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Fri, 27 Jul 2018 11:09:23 -0300 Subject: [PATCH] Makes qbs__trim a tad less thoughtful memory-wise. Addresses #56. --- internal/c/libqb.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 06d78f760..5d8373309 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -6726,20 +6726,7 @@ qbs *qbs_rtrim(qbs *str){ } qbs *qbs__trim(qbs *str){ - if (!str->len) return str; - if ((*str->chr!=32)&&(str->chr[str->len-1]!=32)) return str;//pass on - - qbs *tqbs = NULL; - if (str->tmp&&!str->fixed&&!str->readonly&&!str->in_cmem) { - tqbs=str; - } - else { - tqbs = qbs_new(str->len,1); - memcpy(tqbs->chr,str->chr,str->len); - } - qbs_set(tqbs,qbs_rtrim(qbs_ltrim(tqbs))); - if (tqbs!=str&&str->tmp) qbs_free(str); - return tqbs; + return qbs_rtrim(qbs_ltrim(str)); } int32 func__str_nc_compare(qbs *s1, qbs *s2) {