|
37 | 37 | #include <string.h>
|
38 | 38 | #include "zend_alloc.h"
|
39 | 39 |
|
40 |
| -static const BC_VECTOR POW_10_LUT[9] = { |
41 |
| - 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 |
42 |
| -}; |
43 |
| - |
44 | 40 | /*
|
45 | 41 | * This function should be used when the divisor is not split into multiple chunks, i.e. when the size of the array is one.
|
46 | 42 | * This is because the algorithm can be simplified.
|
@@ -174,8 +170,8 @@ static inline void bc_standard_div(
|
174 | 170 | divisor_top_digits = BC_VECTOR_SIZE;
|
175 | 171 | }
|
176 | 172 |
|
177 |
| - size_t high_part_shift = POW_10_LUT[BC_VECTOR_SIZE - divisor_top_digits + 1]; |
178 |
| - size_t low_part_shift = POW_10_LUT[divisor_top_digits - 1]; |
| 173 | + size_t high_part_shift = BC_POW_10_LUT[BC_VECTOR_SIZE - divisor_top_digits + 1]; |
| 174 | + size_t low_part_shift = BC_POW_10_LUT[divisor_top_digits - 1]; |
179 | 175 | BC_VECTOR divisor_high_part = divisor_vectors[divisor_top_index] * high_part_shift + divisor_vectors[divisor_top_index - 1] / low_part_shift;
|
180 | 176 | for (size_t i = 0; i < quot_arr_size; i++) {
|
181 | 177 | BC_VECTOR numerator_high_part = numerator_vectors[numerator_top_index - i] * high_part_shift + numerator_vectors[numerator_top_index - i - 1] / low_part_shift;
|
@@ -281,7 +277,7 @@ static void bc_do_div(
|
281 | 277 | size_t numerator_read = 0;
|
282 | 278 | if (numerator_bottom_read_len < BC_VECTOR_SIZE) {
|
283 | 279 | numerator_read = MIN(numerator_bottom_read_len, numerator_readable_len);
|
284 |
| - base = POW_10_LUT[numerator_bottom_extension]; |
| 280 | + base = BC_POW_10_LUT[numerator_bottom_extension]; |
285 | 281 | numerator_vectors[numerator_vector_count] = 0;
|
286 | 282 | for (size_t i = 0; i < numerator_read; i++) {
|
287 | 283 | numerator_vectors[numerator_vector_count] += *numerator * base;
|
|
0 commit comments