mhonarc-commits
[Top] [All Lists]

CVS: mhonarc/MHonArc/lib/MHonArc Char.pm,1.3,1.4

2010-12-31 14:34:05
Update of mhonarc/MHonArc/lib/MHonArc
Modified Files:
	Char.pm 
Log Message:
Bug #13853: Added FOLLOWSYMLINKS resource (disabled by default).
Bug #14747: Applied Andrew Shirrayev's patch.
* Include subject of message in some warning messages to make it
  easier to find orginal message causing warning.


======================================================================
FILE: mhonarc/MHonArc/lib/MHonArc/Char.pm
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/MHonArc/Char.pm?rev=1.4>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/MHonArc/Char.pm.diff?r1=1.3&r2=1.4&diff_format=h>
--- Char.pm	26 Dec 2002 21:57:04 -0000	1.3
+++ Char.pm	31 Dec 2010 20:34:00 -0000	1.4
@@ -85,17 +85,24 @@
 
     # Single byte charset
-    my($map, $char);
-    $$data_r =~ s{
-        ([\x00-\xFF])
-    }{
-        foreach $map (@maps) {
-            $char = $map->{$1};
-            last  if defined($char);
-        }
-        unless (defined($char)) {
-            $char = (ord($1) <= 0x7F) ? $1 : '?';
-        }
-        $char;
-    }gxe;
+    # Bug #14747: Performance and memory improvement for single byte
+    #             charsets.  A regex is dynamically built, specific
+    #             to the map(s) provided, so replacement is done
+    #             directly by regex engine.
+    #             Patch provided by Andrew Shirrayev.
+    my($map,$char,$code,%summap,$summap);
+    for ($code=0x00; $code<=0xFF; $code++) {
+        foreach $map (@maps) {
+            $char = $map->{chr($code)};
+            last  if defined($char);
+        }
+        unless (defined($char)) {
+            next if($code <= 0x7F);
+            $char = '?';
+        }
+        $summap{chr($code)} = $char;
+        $summap .= chr($code);
+    }
+    # DO NOT use /o here since we need to recompile each time.
+    $$data_r =~ s/([$summap])/$summap{$1}/ge;
     $$data_r;
 }

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-COMMITS