From 98fdfe103782b23cbce5beb252c22ede75d3e265 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 25 Aug 2024 20:35:41 +0900 Subject: [PATCH] Reduce the number of branch instructions in the `heap_p()` As far as `gcc -S` for several CPU architectures has confirmed, it reduces the number of branch instructions by one. --- src/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gc.c b/src/gc.c index 8763c5208..1b3c335c6 100644 --- a/src/gc.c +++ b/src/gc.c @@ -277,7 +277,7 @@ heap_p(mrb_gc *gc, const struct RBasic *object) RVALUE *p; p = page->objects; - if (&p[0].as.basic <= object && object <= &p[MRB_HEAP_PAGE_SIZE - 1].as.basic) { + if ((uintptr_t)object - (uintptr_t)p <= (MRB_HEAP_PAGE_SIZE - 1) * sizeof(RVALUE)) { return TRUE; } page = page->next;