diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-05-08 10:40:07 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-05-20 21:19:44 +0200 |
commit | 228e69a781c23b2599bbd89f1de29c212f10ea31 (patch) | |
tree | c27f60e9287066fd45afdb14fa103b1ce38e75a8 /pp_pack.c | |
parent | 545872c5eddf1f00b9826a3d8d682387f1c5049d (diff) | |
download | perl-228e69a781c23b2599bbd89f1de29c212f10ea31.tar.gz |
Annotate the "cold" paths in pp_pack.c with UNLIKELY().
The usual case is nice regular bytes in the host's nice regular order.
Diffstat (limited to 'pp_pack.c')
-rw-r--r-- | pp_pack.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -150,11 +150,11 @@ typedef union { /* Only to be used inside a loop (see the break) */ #define SHIFT_BYTES(utf8, s, strend, buf, len, datumtype, needs_swap) \ STMT_START { \ - if (utf8) { \ + if (UNLIKELY(utf8)) { \ if (!uni_to_bytes(aTHX_ &s, strend, \ (char *) (buf), len, datumtype)) break; \ } else { \ - if (needs_swap) \ + if (UNLIKELY(needs_swap)) \ S_reverse_copy(s, (char *) (buf), len); \ else \ Copy(s, (char *) (buf), len, char); \ @@ -292,7 +292,7 @@ uni_to_bytes(pTHX_ const char **s, const char *end, const char *buf, int buf_len UTF8_CHECK_ONLY : (UTF8_CHECK_ONLY | UTF8_ALLOW_ANY); const bool needs_swap = NEEDS_SWAP(datumtype); - if (needs_swap) + if (UNLIKELY(needs_swap)) buf += buf_len; for (;buf_len > 0; buf_len--) { @@ -306,7 +306,7 @@ uni_to_bytes(pTHX_ const char **s, const char *end, const char *buf, int buf_len bad |= 2; val &= 0xff; } - if (needs_swap) + if (UNLIKELY(needs_swap)) *(U8 *)--buf = (U8)val; else *(U8 *)buf++ = (U8)val; @@ -354,7 +354,7 @@ STATIC char * S_bytes_to_uni(const U8 *start, STRLEN len, char *dest, const bool needs_swap) { PERL_ARGS_ASSERT_BYTES_TO_UNI; - if (needs_swap) { + if (UNLIKELY(needs_swap)) { const U8 *p = start + len; while (p-- > start) { const UV uv = NATIVE_TO_ASCII(*p); @@ -383,10 +383,10 @@ S_bytes_to_uni(const U8 *start, STRLEN len, char *dest, const bool needs_swap) { #define PUSH_BYTES(utf8, cur, buf, len, needs_swap) \ STMT_START { \ - if (utf8) \ + if (UNLIKELY(utf8)) \ (cur) = S_bytes_to_uni((U8 *) buf, len, (cur), needs_swap); \ else { \ - if (needs_swap) \ + if (UNLIKELY(needs_swap)) \ S_reverse_copy((char *)(buf), cur, len); \ else \ Copy(buf, cur, len, char); \ |