diff options
author | Karl Williamson <khw@cpan.org> | 2018-01-17 12:40:40 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-01-30 22:58:15 -0700 |
commit | 40e3578e16b821e3d7451b12ef6adaab223ce037 (patch) | |
tree | 7534666972a2e3af97ed03c82b76bbc9c1485b28 /ext | |
parent | 93e25eee77b400afab2c5cb9ad09a5c79ada1eda (diff) | |
download | perl-40e3578e16b821e3d7451b12ef6adaab223ce037.tar.gz |
POSIX::localeconv() Use new fcn; avoid recalcs
This calls strlen() once, instead of passing 0 to the the subsidiary
functions which causes them to call it each time. It also uses the new
function is_utf8_non_invariant_string() instead of doing here what that
function does.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/POSIX.xs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 76fc9a3c77..2ecf2d9a06 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -2171,19 +2171,19 @@ localeconv() const char *value = *((const char **)(ptr + strings->offset)); if (value && *value) { + const STRLEN value_len = strlen(value); + + /* We mark it as UTF-8 if a utf8 locale and is valid and + * variant under UTF-8 */ + const bool is_utf8 = is_utf8_locale + && is_utf8_non_invariant_string( + (U8*) value, + value_len); (void) hv_store(RETVAL, - strings->name, - strlen(strings->name), - newSVpvn_utf8( - value, - strlen(value), - - /* We mark it as UTF-8 if a utf8 locale and is - * valid and variant under UTF-8 */ - is_utf8_locale - && ! is_utf8_invariant_string((U8 *) value, 0) - && is_utf8_string((U8 *) value, 0)), - 0); + strings->name, + strlen(strings->name), + newSVpvn_utf8(value, value_len, is_utf8), + 0); } strings++; } |