[LON-CAPA-cvs] cvs: loncom /localize lonlocal.pm

lueken lueken@source.lon-capa.org
Sun, 01 Feb 2009 21:54:30 -0000


lueken		Sun Feb  1 21:54:30 2009 EDT

  Modified files:              
    /loncom/localize	lonlocal.pm 
  Log:
  Localize Cache: Improvement in the mt function in lonlocal.pm for testing (much faster, final version in the next few days)
  
  
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.53 loncom/localize/lonlocal.pm:1.54
--- loncom/localize/lonlocal.pm:1.53	Fri Jan  2 23:07:52 2009
+++ loncom/localize/lonlocal.pm	Sun Feb  1 21:54:30 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Localization routines
 #
-# $Id: lonlocal.pm,v 1.53 2009/01/02 23:07:52 raeburn Exp $
+# $Id: lonlocal.pm,v 1.54 2009/02/01 21:54:30 lueken Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -179,6 +179,10 @@
 
 # ===================================================== The "MakeText" function
 
+######### Localize Cache
+my @localize_cache;
+#########
+
 sub mt (@) {
 #    open(LOG,'>>/home/www/loncapa/loncom/localize/localize/newphrases.txt');
 #    print LOG (@_[0]."\n");
@@ -191,7 +195,18 @@
                 return $_[0];
             }
         } else {
-            return $lh->maketext(@_);
+				######### Localize Cache
+				foreach my $e (@localize_cache)
+				{
+					if($_[0] eq $$e[0]) { return $$e[1]; }
+				}
+
+				if($#localize_cache == 100) { pop(@localize_cache); }
+				my $localize_entry = $lh->maketext(@_);
+				unshift(@localize_cache, [ @_, $localize_entry ] );
+				#########
+            
+	    		return $localize_entry;
         }
     } else {
 	if (wantarray) {