Skip to content

Commit

Permalink
locale.c: Specially handle the trivial case
Browse files Browse the repository at this point in the history
When setting the numeric radix character, and the locale is C or POSIX,
we know it's going to be a dot without having to look further.  All the
ancillary info is also known.  So save time and just set these all and
return.
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent cf7c121 commit 4353ba0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions locale.c
Expand Up @@ -1615,6 +1615,15 @@ S_new_numeric(pTHX_ const char *newnum)
Safefree(PL_numeric_name);
PL_numeric_name = savepv(newnum);

/* Handle the trivial case */
if (isNAME_C_OR_POSIX(PL_numeric_name)) {
PL_numeric_standard = TRUE;
PL_numeric_underlying_is_standard = TRUE;
PL_numeric_underlying = TRUE;
sv_setpv(PL_numeric_radix_sv, C_decimal_point);
return;
}

/* We are in the underlying locale until changed at the end of this
* function */
PL_numeric_underlying = TRUE;
Expand All @@ -1628,11 +1637,8 @@ S_new_numeric(pTHX_ const char *newnum)

# endif

if (isNAME_C_OR_POSIX(PL_numeric_name)) {
PL_numeric_standard = TRUE;
}
else { /* If its name isn't C nor POSIX, it could still be
indistinguishable from them. */
{ /* If its name isn't C nor POSIX, it could still be indistinguishable
from them. */
const char * scratch_buffer = NULL;

PL_numeric_standard = strEQ(C_decimal_point,
Expand Down

0 comments on commit 4353ba0

Please sign in to comment.