This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames::viacode returning less correct name
There are several cases where more than one name is valid for a code
point. This happens usually when the original name was published with a
typo in it. It's best for viacode to return the revised name, though
the original remains valid.
The names data is in a table generated by mktables exclusively for
charnames, including vianame (and its kin) and viacode. The fix is to
mktables to put the more correct name first in the table, so that it is
found first and returned by viacode().
When I originally designed this code, I thought the correct name should
come last in the tables, so someone looping and reading it could just
overwrite the less correct one with the more correct one.
But to save memory we have the same table shared by viacode and
vianame, and vianame has to recognize both names, so both entries
are needed. viacode could do an rindex to find the more correct name,
but experiments show that that was twice as slow as going the other
direction. Therefore, this patch is for speed.
If the tables for vianame and viacode were ever to be split, this patch
could be reverted, if desired, to put things back to the reverse order.