From 580782bb72b258d6b0fda5f7aab1ae8855461877 Mon Sep 17 00:00:00 2001 From: Gabriel Wicki Date: Tue, 10 May 2022 22:23:40 +0200 Subject: [PATCH] core: Simplify math expressions. * src/gc.c (gc_up_arena): Use division instead of shift. (gc_flip): Simplify (free-news) * 1.5. --- src/gc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gc.c b/src/gc.c index e0b16aa0..4b45069e 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen + * Copyright © 2022 Gabriel Wicki * * This file is part of GNU Mes. * @@ -326,11 +327,11 @@ void gc_up_arena () { long old_arena_bytes = (ARENA_SIZE + JAM_SIZE) * sizeof (struct scm); - if (ARENA_SIZE >> 1 < MAX_ARENA_SIZE >> 2) + if (ARENA_SIZE / 2 < MAX_ARENA_SIZE / 4) { - ARENA_SIZE = ARENA_SIZE << 1; - JAM_SIZE = JAM_SIZE << 1; - GC_SAFETY = GC_SAFETY << 1; + ARENA_SIZE = ARENA_SIZE * 2; + JAM_SIZE = JAM_SIZE * 2; + GC_SAFETY = GC_SAFETY * 2; } else ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE; @@ -448,7 +449,7 @@ void gc_flip () { if (g_free - g_news > JAM_SIZE) - JAM_SIZE = (g_free - g_news) + ((g_free - g_news) / 2); + JAM_SIZE = ((g_free - g_news) * 3) / 2; cell_arena = g_cells - M2_CELL_SIZE; /* For debugging. */ gc_cellcpy (g_cells, g_news, (g_free - g_news) / M2_CELL_SIZE);