This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Remove many #if conditionals
locale.c is full of compiler conditionals because platforms vary widely
(or have in the past) in what categories they use. Prior to this
commit, there were many sections of code which had copies of the same
constructs which were #ifdef'd so they'd run only on the categories that
are to be used in this build.
This duplication creates the opportunity for changes to get applied to
only some of the places that they should, and also makes it hard to
read.
This commit adds two parallel arrays that can map a category to/from its
name, and are defined with each element conditionally compiled in based
on the needs of the build. Doing the conditionals during array
construction means that most of the other conditionals can be replaced
by looping through the arrays. Thus the duplicated code is eliminated,
as well as almost 200 lines in this file.
Most of these loops get executed only at process initialization, so the
slight performance hit is inconsequential.