Skip to content

Commit e97a679

Browse files
committed
drop use of extract_epi16
1 parent af112f6 commit e97a679

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

ext/standard/url.c

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -448,33 +448,6 @@ static int php_htoi(char *s)
448448

449449
static unsigned char hexchars[] = "0123456789ABCDEF";
450450

451-
#ifdef __SSE2__
452-
#ifdef WORDS_BIGENDIAN
453-
#define URL_ENCODE_EXTRACT_BYTE(val, lo, hi) hi = val & 0xff; lo = (val >> 8) & 0xff;
454-
#else
455-
#define URL_ENCODE_EXTRACT_BYTE(val, lo, hi) lo = val & 0xff; hi = (val >> 8) & 0xff;
456-
#endif
457-
#define URL_ENCODE_PHASE(count, bits, to, in) do { \
458-
unsigned char hi, lo; \
459-
uint32_t pair = _mm_extract_epi16(in, count); \
460-
URL_ENCODE_EXTRACT_BYTE(pair, lo, hi); \
461-
if (bits & (0x1 << (count * 2))) { \
462-
*to++ = lo; \
463-
} else { \
464-
*to++ = '%'; \
465-
*to++ = hexchars[lo >> 4]; \
466-
*to++ = hexchars[lo & 0xf]; \
467-
} \
468-
if (bits & (0x1 << (count * 2 + 1))) { \
469-
*to++ = hi; \
470-
} else { \
471-
*to++ = '%'; \
472-
*to++ = hexchars[hi >> 4]; \
473-
*to++ = hexchars[hi & 0xf]; \
474-
} \
475-
} while (0)
476-
#endif
477-
478451
static zend_always_inline zend_string *php_url_encode_impl(const char *s, size_t len, zend_bool raw) /* {{{ */ {
479452
register unsigned char c;
480453
unsigned char *to;
@@ -531,14 +504,18 @@ static zend_always_inline zend_string *php_url_encode_impl(const char *s, size_t
531504
_mm_storeu_si128((__m128i*)to, in);
532505
to += 16;
533506
} else {
534-
URL_ENCODE_PHASE(0, bits, to, in);
535-
URL_ENCODE_PHASE(1, bits, to, in);
536-
URL_ENCODE_PHASE(2, bits, to, in);
537-
URL_ENCODE_PHASE(3, bits, to, in);
538-
URL_ENCODE_PHASE(4, bits, to, in);
539-
URL_ENCODE_PHASE(5, bits, to, in);
540-
URL_ENCODE_PHASE(6, bits, to, in);
541-
URL_ENCODE_PHASE(7, bits, to, in);
507+
int i;
508+
unsigned char xmm[16];
509+
_mm_storeu_si128((__m128i*)xmm, in);
510+
for (i = 0; i < sizeof(xmm); i++) {
511+
if ((bits & (0x1 << i))) {
512+
*to++ = xmm[i];
513+
} else {
514+
*to++ = '%';
515+
*to++ = hexchars[xmm[i] >> 4];
516+
*to++ = hexchars[xmm[i] & 0xf];
517+
}
518+
}
542519
}
543520
from += 16;
544521
}

0 commit comments

Comments
 (0)