core: Simplify math expressions.

* src/gc.c (gc_up_arena): Use division instead of shift.
(gc_flip): Simplify (free-news) * 1.5.
This commit is contained in:
Gabriel Wicki 2022-05-10 22:23:40 +02:00 committed by Jan (janneke) Nieuwenhuizen
parent decc72a4f8
commit 28705c96bd
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*- /* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2022 Gabriel Wicki <gabriel@erlikon.ch>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -326,11 +327,11 @@ void
gc_up_arena () gc_up_arena ()
{ {
long old_arena_bytes = (ARENA_SIZE + JAM_SIZE) * sizeof (struct scm); 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; ARENA_SIZE = ARENA_SIZE * 2;
JAM_SIZE = JAM_SIZE << 1; JAM_SIZE = JAM_SIZE * 2;
GC_SAFETY = GC_SAFETY << 1; GC_SAFETY = GC_SAFETY * 2;
} }
else else
ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE; ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE;
@ -448,7 +449,7 @@ void
gc_flip () gc_flip ()
{ {
if (g_free - g_news > JAM_SIZE) 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. */ cell_arena = g_cells - M2_CELL_SIZE; /* For debugging. */
gc_cellcpy (g_cells, g_news, (g_free - g_news) / M2_CELL_SIZE); gc_cellcpy (g_cells, g_news, (g_free - g_news) / M2_CELL_SIZE);