From ca310d35adff11036ba9055d0b52454e57c94e99 Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Fri, 3 Jan 2025 22:38:50 +0100 Subject: [PATCH] filterx/filterx-ref: move filterx_ref_new() fastpath to an inline function Signed-off-by: Balazs Scheidler --- lib/filterx/filterx-ref.c | 6 ++---- lib/filterx/filterx-ref.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/filterx/filterx-ref.c b/lib/filterx/filterx-ref.c index 08f7b8052..75f155c08 100644 --- a/lib/filterx/filterx-ref.c +++ b/lib/filterx/filterx-ref.c @@ -238,12 +238,10 @@ _filterx_ref_add(FilterXObject *s, FilterXObject *object) return filterx_object_add_object(self->value, object); } +/* NOTE: fastpath is in the header as an inline function */ FilterXObject * -filterx_ref_new(FilterXObject *value) +_filterx_ref_new(FilterXObject *value) { - if (!value || value->readonly || !_filterx_type_is_referenceable(value->type)) - return value; - if (filterx_object_is_type(value, &FILTERX_TYPE_NAME(ref))) { FilterXRef *absorbed_ref = (FilterXRef *) value; diff --git a/lib/filterx/filterx-ref.h b/lib/filterx/filterx-ref.h index 9e68cfe72..88d5d6035 100644 --- a/lib/filterx/filterx-ref.h +++ b/lib/filterx/filterx-ref.h @@ -48,8 +48,6 @@ typedef struct _FilterXRef } FilterXRef; -FilterXObject *filterx_ref_new(FilterXObject *value); - /* Call them only where downcasting to a specific type is needed, the returned object should only be used locally. */ FilterXObject *filterx_ref_unwrap_ro(FilterXObject *s); FilterXObject *filterx_ref_unwrap_rw(FilterXObject *s); @@ -60,4 +58,14 @@ _filterx_type_is_referenceable(FilterXType *t) return t->is_mutable && t != &FILTERX_TYPE_NAME(ref); } +FilterXObject *_filterx_ref_new(FilterXObject *value); + +static inline FilterXObject * +filterx_ref_new(FilterXObject *value) +{ + if (!value || value->readonly || !_filterx_type_is_referenceable(value->type)) + return value; + return _filterx_ref_new(value); +} + #endif