diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-03-21 20:32:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-03-21 20:32:31 -0700 |
commit | 7fcd263dbcf065646caf031b087f06b6a2517390 (patch) | |
tree | c7fba094aced52b976f882991ebf402d2ad99928 | |
parent | dbfdcc09df531c65ff34fab4818fa9fd5e6babb0 (diff) | |
download | txr-7fcd263dbcf065646caf031b087f06b6a2517390.tar.gz txr-7fcd263dbcf065646caf031b087f06b6a2517390.tar.bz2 txr-7fcd263dbcf065646caf031b087f06b6a2517390.zip |
rand: eliminate small static function called only once.
* rand.c (make_state): Static function removed.
(make_random_state): make_state logic integrated into
this one and only caller.
-rw-r--r-- | rand.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -89,12 +89,6 @@ static rand32_t rand_tab[16] = { 0x88A74E05U, 0xC1CBAEC2U, 0x8170BEADU, 0x29FAF776U }; -static val make_state(void) -{ - struct rand_state *r = coerce(struct rand_state *, chk_malloc(sizeof *r)); - return cobj(coerce(mem_t *, r), random_state_cls, &random_state_ops); -} - val random_state_p(val obj) { return cobjclassp(obj, random_state_cls); @@ -148,9 +142,9 @@ static rand32_t (*rand32)(struct rand_state *) = rand32_good; val make_random_state(val seed, val warmup) { val self = lit("make-random-state"); - val rs = make_state(); + struct rand_state *r = coerce(struct rand_state *, chk_malloc(sizeof *r)); + val rs = cobj(coerce(mem_t *, r), random_state_cls, &random_state_ops); int i = 0; - struct rand_state *r = coerce(struct rand_state *, rs->co.handle); seed = default_null_arg(seed); warmup = default_null_arg(warmup); |