Skip to content

Commit f39357b

Browse files
committed
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.
1 parent 304c9c3 commit f39357b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

ext/random/engine_mt19937.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ PHP_METHOD(Random_Engine_Mt19937, __construct)
282282
}
283283
}
284284

285-
engine->algo->seed(engine->status, seed);
285+
mt19937_seed_state(state, seed);
286286
}
287287
/* }}} */
288288

ext/random/engine_pcgoneseq128xslrr64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ PHP_METHOD(Random_Engine_PcgOneseq128XslRr64, __construct)
177177
RETURN_THROWS();
178178
}
179179
} else {
180-
engine->algo->seed(engine->status, int_seed);
180+
seed128(state, php_random_uint128_constant(0ULL, (uint64_t) int_seed));
181181
}
182182
}
183183
}

ext/random/engine_xoshiro256starstar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ PHP_METHOD(Random_Engine_Xoshiro256StarStar, __construct)
246246
RETURN_THROWS();
247247
}
248248
} else {
249-
engine->algo->seed(engine->status, (uint64_t) int_seed);
249+
seed64(state, (uint64_t) int_seed);
250250
}
251251
}
252252
}

0 commit comments

Comments
 (0)