Skip to content

Commit

Permalink
filterx/filterx-ref: move filterx_ref_new() fastpath to an inline fun…
Browse files Browse the repository at this point in the history
…ction

Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed Jan 7, 2025
1 parent 772562a commit 719cce3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/filterx/filterx-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions lib/filterx/filterx-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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

0 comments on commit 719cce3

Please sign in to comment.