[Koha-patches] [PATCH] Improve C4::Charset::MarcToUTF8Record performance

Frederic Demians f.demians at tamil.fr
Sat Oct 25 10:38:37 CEST 2008


A script like bulkmarkimport.pl spends most of the time
in C4::Charset::MarcToUTF8Record function, and
specifically in C4::Charset::char_decode5426
just initializing a hash. This patch moves this
hash outside function to avoid its initializing
each time the functon is called.

A test on a specific conversion script shows me
that performances were improved from 23s to 8s.
---
 C4/Charset.pm |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/C4/Charset.pm b/C4/Charset.pm
index a676b7c..4b73ceb 100644
--- a/C4/Charset.pm
+++ b/C4/Charset.pm
@@ -620,9 +620,7 @@ Converts a string from ISO-5426 to UTF-8.
 
 =cut
 
-sub char_decode5426 {
-    my ( $string) = @_;
-    my $result;
+
 my %chars;
 $chars{0xb0}=0x0101;#3/0ayn[ain]
 $chars{0xb1}=0x0623;#3/1alif/hamzah[alefwithhamzaabove]
@@ -995,6 +993,11 @@ $chars{0xda20}=0x02cc; #
         # 5/14 right half of ligature sign
         # 5/15 right half of double tilde
 #     map {printf "%x :%x\n",$_,$chars{$_};}keys %chars;
+
+sub char_decode5426 {
+    my ( $string) = @_;
+    my $result;
+
     my @data = unpack("C*", $string);
     my @characters;
     my $length=scalar(@data);
-- 
1.5.5.GIT




More information about the Koha-patches mailing list