For the LC_NUMERIC locale category, one can swap between setlocale being
to "C" or to the underlying locale. Perl keeps track of the state
using two boolean variables. By testing these before calling the swap
functions, we can skip calling them if the current state is the one we
want to be in, and avoid the function call overhead, as the function
becomes a no-op if the current state is the desired one.
/* The next two macros set unconditionally. These should be rarely used, and
* only after being sure that this is what is needed */
-#define SET_NUMERIC_STANDARD() \
- set_numeric_standard();
+#define SET_NUMERIC_STANDARD() \
+ STMT_START { if (! PL_numeric_standard) set_numeric_standard(); \
+ } STMT_END
-#define SET_NUMERIC_LOCAL() \
- set_numeric_local();
+#define SET_NUMERIC_LOCAL() \
+ STMT_START { if (! PL_numeric_local) set_numeric_local(); } STMT_END
/* The rest of these LC_NUMERIC macros toggle to one or the other state, with
* the RESTORE_foo ones called to switch back, but only if need be */