From f39357b07bd34fd03a673180e7eb07ec52261b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 29 Jan 2024 17:00:11 +0100 Subject: [PATCH] random: Call int-seeding functions directly As the `__construct()` implementation is engine-specific anyway, we know what engine were dealing with and can just call the seeding function directly instead of going through a function pointer. This likely improves construction performance a little, but I did not measure. --- ext/random/engine_mt19937.c | 2 +- ext/random/engine_pcgoneseq128xslrr64.c | 2 +- ext/random/engine_xoshiro256starstar.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/random/engine_mt19937.c b/ext/random/engine_mt19937.c index 377526550a6..7559f148615 100644 --- a/ext/random/engine_mt19937.c +++ b/ext/random/engine_mt19937.c @@ -282,7 +282,7 @@ PHP_METHOD(Random_Engine_Mt19937, __construct) } } - engine->algo->seed(engine->status, seed); + mt19937_seed_state(state, seed); } /* }}} */ diff --git a/ext/random/engine_pcgoneseq128xslrr64.c b/ext/random/engine_pcgoneseq128xslrr64.c index 107e5528467..b0d6d418f32 100644 --- a/ext/random/engine_pcgoneseq128xslrr64.c +++ b/ext/random/engine_pcgoneseq128xslrr64.c @@ -177,7 +177,7 @@ PHP_METHOD(Random_Engine_PcgOneseq128XslRr64, __construct) RETURN_THROWS(); } } else { - engine->algo->seed(engine->status, int_seed); + seed128(state, php_random_uint128_constant(0ULL, (uint64_t) int_seed)); } } } diff --git a/ext/random/engine_xoshiro256starstar.c b/ext/random/engine_xoshiro256starstar.c index c4f71c0c3d9..51971833b55 100644 --- a/ext/random/engine_xoshiro256starstar.c +++ b/ext/random/engine_xoshiro256starstar.c @@ -246,7 +246,7 @@ PHP_METHOD(Random_Engine_Xoshiro256StarStar, __construct) RETURN_THROWS(); } } else { - engine->algo->seed(engine->status, (uint64_t) int_seed); + seed64(state, (uint64_t) int_seed); } } }