From 3a90afd1d07b9403e5f52db5608e22930faff376 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sun, 12 Apr 2026 00:12:00 -0700 Subject: Avoid atomic exchange in rb_free_tmp_buffer Usually RB_ALLOCV_N uses alloca for small allocations, and in that case the value is 0, and we should not need to atomic exchange it back to 0. I'm actually not sure why we need atomic operations here anyways. --- imemo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/imemo.c b/imemo.c index ce27ea5601..fc557a3144 100644 --- a/imemo.c +++ b/imemo.c @@ -89,6 +89,7 @@ rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt) void rb_free_tmp_buffer(volatile VALUE *store) { + if (!*store) return; rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0); if (s) { void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0); -- cgit v1.2.3