summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-02-13 22:10:19 -0700
committerKarl Williamson <public@khwilliamson.com>2013-08-29 09:55:50 -0600
commit9ff651ce1ced9c225b5fa63d6825396dc3f96fe7 (patch)
tree347bb294947d778325cde744ae0c13bc36739c20
parent67af0a71470eeb7adf1b58773a5db09f3cc5cb70 (diff)
downloadperl-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.h10
-rw-r--r--regcomp.c9
-rw-r--r--sv.c10
3 files changed, 13 insertions, 16 deletions
diff --git a/inline.h b/inline.h
index 63a5e064d1..b95663fc07 100644
--- a/inline.h
+++ b/inline.h
@@ -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);
}
}
diff --git a/regcomp.c b/regcomp.c
index 78773e6baa..054273df8c 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -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) {
diff --git a/sv.c b/sv.c
index 8ba05050ae..ee69bf8ba2 100644
--- a/sv.c
+++ b/sv.c
@@ -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--;
}
}