From: Willy Tarreau Date: Mon, 25 Apr 2022 08:02:11 +0000 (+0200) Subject: MINOR: sample: don't needlessly call c_none() in sample_fetch_as_type() X-Git-Tag: v2.6-dev8~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3705deea99ac557c74125b7302dd15082585d76c;p=thirdparty%2Fhaproxy.git MINOR: sample: don't needlessly call c_none() in sample_fetch_as_type() 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. --- diff --git a/src/sample.c b/src/sample.c index f43a79ed31..1278ef9387 100644 --- a/src/sample.c +++ b/src/sample.c @@ -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;