Skip to content

Commit ca468be

Browse files
committed
ext/standard: Remove redundant if-branch in rot13
1 parent f49cdd4 commit ca468be

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

‎UPGRADING‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ PHP 8.7 UPGRADE NOTES
7979
- Standard:
8080
. Improved performance of array_splice() when inserting without removing
8181
elements.
82+
. Improved performance of str_rot13().

‎ext/standard/string.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6054,34 +6054,26 @@ static zend_string *php_str_rot13(zend_string *str)
60546054
gt = _mm_cmpgt_epi8(in, a_minus_1);
60556055
lt = _mm_cmplt_epi8(in, m_plus_1);
60566056
cmp = _mm_and_si128(lt, gt);
6057-
if (_mm_movemask_epi8(cmp)) {
6058-
cmp = _mm_and_si128(cmp, add);
6059-
delta = _mm_or_si128(delta, cmp);
6060-
}
6057+
cmp = _mm_and_si128(cmp, add);
6058+
delta = _mm_or_si128(delta, cmp);
60616059

60626060
gt = _mm_cmpgt_epi8(in, n_minus_1);
60636061
lt = _mm_cmplt_epi8(in, z_plus_1);
60646062
cmp = _mm_and_si128(lt, gt);
6065-
if (_mm_movemask_epi8(cmp)) {
6066-
cmp = _mm_and_si128(cmp, sub);
6067-
delta = _mm_or_si128(delta, cmp);
6068-
}
6063+
cmp = _mm_and_si128(cmp, sub);
6064+
delta = _mm_or_si128(delta, cmp);
60696065

60706066
gt = _mm_cmpgt_epi8(in, A_minus_1);
60716067
lt = _mm_cmplt_epi8(in, M_plus_1);
60726068
cmp = _mm_and_si128(lt, gt);
6073-
if (_mm_movemask_epi8(cmp)) {
6074-
cmp = _mm_and_si128(cmp, add);
6075-
delta = _mm_or_si128(delta, cmp);
6076-
}
6069+
cmp = _mm_and_si128(cmp, add);
6070+
delta = _mm_or_si128(delta, cmp);
60776071

60786072
gt = _mm_cmpgt_epi8(in, N_minus_1);
60796073
lt = _mm_cmplt_epi8(in, Z_plus_1);
60806074
cmp = _mm_and_si128(lt, gt);
6081-
if (_mm_movemask_epi8(cmp)) {
6082-
cmp = _mm_and_si128(cmp, sub);
6083-
delta = _mm_or_si128(delta, cmp);
6084-
}
6075+
cmp = _mm_and_si128(cmp, sub);
6076+
delta = _mm_or_si128(delta, cmp);
60856077

60866078
in = _mm_add_epi8(in, delta);
60876079
_mm_storeu_si128((__m128i *)target, in);

0 commit comments

Comments
 (0)