Skip to content

Commit e55e0e2

Browse files
committed
Added comments
1 parent 1189f4f commit e55e0e2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ext/bcmath/libbcmath/src/str2num.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,22 @@ static const char *bc_count_digits(const char *str, const char *end)
7878

7979
static inline const char *bc_skip_zero_reverse(const char *str, const char *end)
8080
{
81-
81+
/* Check in bulk */
8282
#ifdef __SSE2__
8383
const __m128i c_zero_repeat = _mm_set1_epi8((signed char) '0');
8484
while (str - sizeof(__m128i) >= end) {
8585
str -= sizeof(__m128i);
8686
__m128i bytes = _mm_loadu_si128((const __m128i *) str);
87+
/* Checks if all numeric strings are equal to '0'. */
8788
bytes = _mm_cmpeq_epi8(bytes, c_zero_repeat);
8889

8990
int mask = _mm_movemask_epi8(bytes);
91+
/*
92+
* The probability of having 16 trailing 0s in a row is very low, so we use EXPECTED.
93+
* Move the pointer back and check each character in loop.
94+
*/
9095
if (EXPECTED(mask != 0xffff)) {
96+
/* */
9197
str += sizeof(__m128i);
9298
break;
9399
}
@@ -138,6 +144,7 @@ bool bc_str2num(bc_num *num, const char *str, const char *end, size_t scale, boo
138144
if (decimal_point) {
139145
/* search */
140146
fractional_ptr = fractional_end = decimal_point + 1;
147+
/* For strings that end with a decimal point, such as "012." */
141148
if (UNEXPECTED(*fractional_ptr == '\0')) {
142149
goto after_fractional;
143150
}

0 commit comments

Comments
 (0)