]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: use smp_make_rw() in upper/lower converters
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 12:29:38 +0000 (14:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 12:31:25 +0000 (14:31 +0200)
There's no point in always duplicating the sample, just ensure it's
writable, as was done prior to the smp_dup() change. This should be
backported to 1.6 to avoid a performance regression caused by this
change (about 30% more time for upper/lower due to the copy).

src/sample.c

index e0a880ec6f366d0ad2e10115d646b767aedd7922..77cbd1bf34d495d48d063e639b78963db05f5f62 100644 (file)
@@ -1474,10 +1474,7 @@ static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp, vo
 {
        int i;
 
-       if (!smp_dup(smp))
-               return 0;
-
-       if (!smp->data.u.str.size)
+       if (!smp_make_rw(smp))
                return 0;
 
        for (i = 0; i < smp->data.u.str.len; i++) {
@@ -1491,10 +1488,7 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp, vo
 {
        int i;
 
-       if (!smp_dup(smp))
-               return 0;
-
-       if (!smp->data.u.str.size)
+       if (!smp_make_rw(smp))
                return 0;
 
        for (i = 0; i < smp->data.u.str.len; i++) {