Skip to content

Commit 62aa8fa

Browse files
committed
random: Reduce variable scope in Random\Engine\PcgOneseq128XslRr64::__construct()
This is for consistency with xoshiro256**'s constructor.
1 parent 8d7364f commit 62aa8fa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/random/engine_pcgoneseq128xslrr64.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ PHP_METHOD(Random_Engine_PcgOneseq128XslRr64, __construct)
146146
zend_string *str_seed = NULL;
147147
zend_long int_seed = 0;
148148
bool seed_is_null = true;
149-
uint32_t i, j;
150-
uint64_t t[2];
151149

152150
ZEND_PARSE_PARAMETERS_START(0, 1)
153151
Z_PARAM_OPTIONAL;
@@ -163,13 +161,16 @@ PHP_METHOD(Random_Engine_PcgOneseq128XslRr64, __construct)
163161
if (str_seed) {
164162
/* char (byte: 8 bit) * 16 = 128 bits */
165163
if (ZSTR_LEN(str_seed) == 16) {
164+
uint64_t t[2];
165+
166166
/* Endianness safe copy */
167-
for (i = 0; i < 2; i++) {
167+
for (uint32_t i = 0; i < 2; i++) {
168168
t[i] = 0;
169-
for (j = 0; j < 8; j++) {
169+
for (uint32_t j = 0; j < 8; j++) {
170170
t[i] += ((uint64_t) (unsigned char) ZSTR_VAL(str_seed)[(i * 8) + j]) << (j * 8);
171171
}
172172
}
173+
173174
seed128(engine->status, php_random_uint128_constant(t[0], t[1]));
174175
} else {
175176
zend_argument_value_error(1, "must be a 16 byte (128 bit) string");

0 commit comments

Comments
 (0)