]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: don't needlessly call c_none() in sample_fetch_as_type()
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 08:02:11 +0000 (10:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 14:09:26 +0000 (16:09 +0200)
Surprisingly, while about all calls to a sample cast function carefully
avoid calling c_none(), sample_fetch_as_type() makes no effort regarding
this, while by nature, the function is most often called with an expected
output type similar to the one of the expresison. Let's add it to shorten
the most common call path.

src/sample.c

index f43a79ed31473f607911fe55434805eab5143456..1278ef9387c85f626d1a02ee378c92f9f690532a 100644 (file)
@@ -1564,7 +1564,8 @@ struct sample *sample_fetch_as_type(struct proxy *px, struct session *sess,
        if (!sample_casts[smp->data.type][smp_type])
                return NULL;
 
-       if (!sample_casts[smp->data.type][smp_type](smp))
+       if (sample_casts[smp->data.type][smp_type] != c_none &&
+           !sample_casts[smp->data.type][smp_type](smp))
                return NULL;
 
        smp->flags &= ~SMP_F_MAY_CHANGE;