This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8_heavy: Skip unnecessary operations
authorKarl Williamson <public@khwilliamson.com>
Sat, 19 Nov 2011 21:22:00 +0000 (14:22 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 13 Jan 2012 16:58:32 +0000 (09:58 -0700)
The mktables generated tables are well-formed, already sorted, and with
no extra items such as "+utf8::foo".  Thus we don't have to do these
operations on them, but they are required on user-defined properties,
and should $list be passed in as a parameter.

This patch moves the code that does this to just the user-defined area

lib/utf8_heavy.pl

index 225a99e..29b974e 100644 (file)
@@ -101,6 +101,9 @@ sub _loose_name ($) {
         # Change this to get a different set of Unicode tables
         my $unicore_dir = 'unicore';
         my $invert_it = 0;
+        my $list_is_from_mktables = 0;  # Is $list returned from a mktables
+                                        # generated file?  If so, we know it's
+                                        # well behaved.
 
         if ($type)
         {
@@ -508,17 +511,21 @@ sub _loose_name ($) {
                 local $@;
                 local $!;
                 $list = do $file; die $@ if $@;
+                $list_is_from_mktables = 1;
             }
         } # End of $type is non-null
 
         # Here, either $type was null, or we found the requested property and
         # read it into $list
 
-        my $extras;
+        my $extras = "";
 
         my $bits = $minbits;
 
-        if ($list) {
+        # mktables lists don't have extras, like '&utf8::prop', so don't need
+        # to separate them; also lists are already sorted, so don't need to do
+        # that.
+        if ($list && ! $list_is_from_mktables) {
             my $taint = substr($list,0,0); # maintain taint
 
             # Separate the extras from the code point list, and for