]> git.mjollnir.org Git - moodle.git/commitdiff
Keep strings cached in memory during a single page to improve performance
authormoodler <moodler>
Thu, 3 Jul 2003 12:19:54 +0000 (12:19 +0000)
committermoodler <moodler>
Thu, 3 Jul 2003 12:19:54 +0000 (12:19 +0000)
on slow filesystems or bad file caching.   (experimental)

lib/moodlelib.php

index 27d42cbec1e52468f4390b8c26d1418b81493d53..3103352cf01315684f9f1a21000d1e7e8eb16e5d 100644 (file)
@@ -1043,7 +1043,15 @@ function get_string($identifier, $module="", $a=NULL) {
 
 function get_string_from_file($identifier, $langfile, $destination) {
 /// This function is only used from get_string().
-    include ($langfile);
+
+    static $strings;    // Keep the strings cached in memory.
+
+    if (empty($strings[$langfile])) {
+        include ($langfile);
+        $strings[$langfile] = $string;
+    } else {
+        $string = &$strings[$langfile];
+    }
 
     if (!isset ($string[$identifier])) {
         return false;