From 415d555736d1b76de4e078e063eff5207b1b8f96 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Fri, 23 Jan 2026 21:05:22 +0100 Subject: [PATCH] resizable: Inline some function in apfl_resizable_append Profiling revealed that this gets called quite a lot --- src/resizable.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/resizable.c b/src/resizable.c index 7bb642f..ff038b3 100644 --- a/src/resizable.c +++ b/src/resizable.c @@ -215,15 +215,28 @@ apfl_resizable_splice( bool apfl_resizable_append(struct apfl_allocator allocator, size_t elem_size, void **mem, size_t *len, size_t *cap, const void *other_mem, size_t other_len) { - return apfl_resizable_splice( + if (other_len == 0 || other_mem == NULL) { + return true; + } + + if (!apfl_resizable_ensure_cap_for_more_elements( allocator, elem_size, mem, - len, - cap, *len, - 0, - other_mem, + cap, other_len + )) { + return false; + } + + memcpy( + ((char *)(*mem)) + *len * elem_size, + other_mem, + other_len * elem_size ); + + *len += other_len; + + return true; }