cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 0fdbe052dcf45546e1b78b731ba2529c2b655396
parent f8224f9d814b111e9841c8c3e9735046290b55a6
Author: Michael Forney <mforney@mforney.org>
Date:   Thu, 14 Mar 2019 18:35:40 -0700

Don't need a table of int maximums

Diffstat:
Mexpr.c | 8+-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/expr.c b/expr.c @@ -241,12 +241,6 @@ inttype(uint64_t val, bool decimal, char *end) {&typellong, "ll", NULL}, {&typeullong, "ull", "llu"}, }; - static const uint64_t max[] = { - [1] = 0xff, - [2] = 0xffff, - [4] = 0xffffffff, - [8] = 0xffffffffffffffff, - }; struct type *t; size_t i, step; @@ -263,7 +257,7 @@ inttype(uint64_t val, bool decimal, char *end) step = i % 2 || decimal ? 2 : 1; for (; i < LEN(limits); i += step) { t = limits[i].type; - if (val <= max[t->size] >> t->basic.issigned) + if (val <= (uint64_t)-1 >> (8 - t->size << 3) + t->basic.issigned) return t; } error(&tok.loc, "no suitable type for constant '%s'", tok.lit);