summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-01-30 11:09:01 -0700
committerKarl Williamson <khw@cpan.org>2019-02-04 21:00:50 -0700
commit78ed8e3629d58d11345e4367dbe14b9603e8c84b (patch)
tree00480d7a4b03f540320feeeed728e3f70f597252 /pp.c
parent93327b758a54c8e1ff7ee137a513caff4d077a7d (diff)
downloadperl-78ed8e3629d58d11345e4367dbe14b9603e8c84b.tar.gz
pp.c: Don't use function call for easy copy
Like the previous commit, this code is adding the UTF-8 for a Greek character to a string. It previously used Copy, but this character is representable as two bytes in both ASCII and EBCDIC UTF-8, the only character sets that Perl will ever supports, so we can use the specialized code that is used most everywhere else for two byte UTF-8 characters, avoiding the function overhead, and having to treat this character as particularly special.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/pp.c b/pp.c
index 6191b48761..01b979e366 100644
--- a/pp.c
+++ b/pp.c
@@ -31,7 +31,6 @@
#include "reentr.h"
#include "regcharclass.h"
-static const STRLEN capital_iota_len = sizeof(GREEK_CAPITAL_LETTER_IOTA_UTF8) - 1;
/* variations on pp_null */
PP(pp_stub)
@@ -4019,6 +4018,8 @@ PP(pp_uc)
const U8 *const send = s + len;
U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
+#define GREEK_CAPITAL_LETTER_IOTA 0x0399
+#define COMBINING_GREEK_YPOGEGRAMMENI 0x0345
/* All occurrences of these are to be moved to follow any other marks.
* This is context-dependent. We may not be passed enough context to
* move the iota subscript beyond all of them, but we do the best we can
@@ -4038,8 +4039,8 @@ PP(pp_uc)
if (in_iota_subscript && ! _is_utf8_mark(s)) {
/* A non-mark. Time to output the iota subscript */
- Copy(GREEK_CAPITAL_LETTER_IOTA_UTF8, d, capital_iota_len, U8);
- d += capital_iota_len;
+ *d++ = UTF8_TWO_BYTE_HI(GREEK_CAPITAL_LETTER_IOTA);
+ *d++ = UTF8_TWO_BYTE_LO(GREEK_CAPITAL_LETTER_IOTA);
in_iota_subscript = FALSE;
}
@@ -4052,8 +4053,6 @@ PP(pp_uc)
#else
uv = _toUPPER_utf8_flags(s, send, tmpbuf, &ulen, 0);
#endif
-#define GREEK_CAPITAL_LETTER_IOTA 0x0399
-#define COMBINING_GREEK_YPOGEGRAMMENI 0x0345
if (uv == GREEK_CAPITAL_LETTER_IOTA
&& utf8_to_uvchr_buf(s, send, 0) == COMBINING_GREEK_YPOGEGRAMMENI)
{
@@ -4079,8 +4078,8 @@ PP(pp_uc)
s += u;
}
if (in_iota_subscript) {
- Copy(GREEK_CAPITAL_LETTER_IOTA_UTF8, d, capital_iota_len, U8);
- d += capital_iota_len;
+ *d++ = UTF8_TWO_BYTE_HI(GREEK_CAPITAL_LETTER_IOTA);
+ *d++ = UTF8_TWO_BYTE_LO(GREEK_CAPITAL_LETTER_IOTA);
}
SvUTF8_on(dest);
*d = '\0';