summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-03-21 20:32:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-03-21 20:32:31 -0700
commit7fcd263dbcf065646caf031b087f06b6a2517390 (patch)
treec7fba094aced52b976f882991ebf402d2ad99928
parentdbfdcc09df531c65ff34fab4818fa9fd5e6babb0 (diff)
downloadtxr-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.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/rand.c b/rand.c
index 746b5e47..4d068826 100644
--- a/rand.c
+++ b/rand.c
@@ -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);