diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-02-13 22:10:19 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-08-29 09:55:50 -0600 |
commit | 9ff651ce1ced9c225b5fa63d6825396dc3f96fe7 (patch) | |
tree | 347bb294947d778325cde744ae0c13bc36739c20 | |
parent | 67af0a71470eeb7adf1b58773a5db09f3cc5cb70 (diff) | |
download | perl-9ff651ce1ced9c225b5fa63d6825396dc3f96fe7.tar.gz |
Remove unnecessary temp variable in converting to UTF-8
These areas of code included a temporary that is unnecessary.
-rw-r--r-- | inline.h | 10 | ||||
-rw-r--r-- | regcomp.c | 9 | ||||
-rw-r--r-- | sv.c | 10 |
3 files changed, 13 insertions, 16 deletions
@@ -209,15 +209,13 @@ S_append_utf8_from_native_byte(const U8 byte, U8** dest) /* Takes an input 'byte' (Latin1 or EBCDIC) and appends it to the UTF-8 * encoded string at '*dest', updating '*dest' to include it */ - const U8 uv = NATIVE_TO_LATIN1(byte); - PERL_ARGS_ASSERT_APPEND_UTF8_FROM_NATIVE_BYTE; - if (UNI_IS_INVARIANT(uv)) - *(*dest)++ = UNI_TO_NATIVE(uv); + if (NATIVE_IS_INVARIANT(byte)) + *(*dest)++ = byte; else { - *(*dest)++ = UTF8_EIGHT_BIT_HI(uv); - *(*dest)++ = UTF8_EIGHT_BIT_LO(uv); + *(*dest)++ = UTF8_EIGHT_BIT_HI(byte); + *(*dest)++ = UTF8_EIGHT_BIT_LO(byte); } } @@ -4950,12 +4950,11 @@ S_pat_upgrade_to_utf8(pTHX_ RExC_state_t * const pRExC_state, Newx(dst, *plen_p * 2 + 1, U8); while (s < *plen_p) { - const UV uv = NATIVE_TO_ASCII(src[s]); - if (UNI_IS_INVARIANT(uv)) - dst[d] = (U8)UTF_TO_NATIVE(uv); + if (NATIVE_IS_INVARIANT(src[s])) + dst[d] = src[s]; else { - dst[d++] = (U8)UTF8_EIGHT_BIT_HI(uv); - dst[d] = (U8)UTF8_EIGHT_BIT_LO(uv); + dst[d++] = UTF8_EIGHT_BIT_HI(src[s]); + dst[d] = UTF8_EIGHT_BIT_LO(src[s]); } if (n < num_code_blocks) { if (!do_end && pRExC_state->code_blocks[n].start == s) { @@ -3469,13 +3469,13 @@ must_be_utf8: e--; while (e >= t) { - const U8 ch = NATIVE8_TO_UNI(*e--); - if (UNI_IS_INVARIANT(ch)) { - *d-- = UNI_TO_NATIVE(ch); + if (NATIVE_IS_INVARIANT(*e)) { + *d-- = *e; } else { - *d-- = (U8)UTF8_EIGHT_BIT_LO(ch); - *d-- = (U8)UTF8_EIGHT_BIT_HI(ch); + *d-- = UTF8_EIGHT_BIT_LO(*e); + *d-- = UTF8_EIGHT_BIT_HI(*e); } + e--; } } |