This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames::viacode returning less correct name
authorKarl Williamson <public@khwilliamson.com>
Fri, 15 Oct 2010 01:36:04 +0000 (19:36 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 21 Oct 2010 12:54:20 +0000 (05:54 -0700)
commit53d84487fbdd2060c1a666eacaef6e34ce4a1483
tree763a20d52bc4763c68af086590ec76e4d05be95e
parent969a34cc81e0088cad802e53b05376b1280dedbb
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.
lib/charnames.t
lib/unicore/mktables