Skip to content

Commit 81d3704

Browse files
committed
Remove superfluous helper variable in Randomizer::getBytes()
1 parent d64aa6f commit 81d3704

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ext/random/randomizer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ PHP_METHOD(Random_Randomizer, getBytes)
142142
zend_string *retval;
143143
zend_long length;
144144
uint64_t result;
145-
size_t total_size = 0, required_size;
145+
size_t total_size = 0;
146146

147147
ZEND_PARSE_PARAMETERS_START(1, 1)
148148
Z_PARAM_LONG(length)
@@ -154,17 +154,16 @@ PHP_METHOD(Random_Randomizer, getBytes)
154154
}
155155

156156
retval = zend_string_alloc(length, 0);
157-
required_size = length;
158157

159-
while (total_size < required_size) {
158+
while (total_size < length) {
160159
result = randomizer->algo->generate(randomizer->status);
161160
if (EG(exception)) {
162161
zend_string_free(retval);
163162
RETURN_THROWS();
164163
}
165164
for (size_t i = 0; i < randomizer->status->last_generated_size; i++) {
166165
ZSTR_VAL(retval)[total_size++] = (result >> (i * 8)) & 0xff;
167-
if (total_size >= required_size) {
166+
if (total_size >= length) {
168167
break;
169168
}
170169
}

0 commit comments

Comments
 (0)