[Atoms] Speed up atomsDESCRIPTIONget using cache. 31/8531/2
Bruno JOFRET [Fri, 3 Aug 2012 15:21:10 +0000 (17:21 +0200)]
Change-Id: I47a2bfbaafff123eebd8472f7d129a4b705d0503

scilab/modules/atoms/macros/atoms_internals/atomsDESCRIPTIONget.sci
scilab/modules/ui_data/src/cpp/UpdateBrowseVar.cpp

index 6fc1d7b..2d9aa31 100644 (file)
@@ -225,12 +225,21 @@ function [packages,categories_flat,categories] = atomsDESCRIPTIONget(update)
     if ierr <> 0 then
       error(msprintf(gettext("%s: save (''%s'') has failed.\n"),"atomsDESCRIPTIONget", packages_path));
     end
+    clearglobal %_atoms_cache;
 
   // Just load from file
   // =========================================================================
 
   else
-    load(packages_path,"packages","categories","categories_flat");
+      global %_atoms_cache; // /!\ Do not rename this variable. Name is tracked/ignored by Variable Browser
+      if isempty(%_atoms_cache) then
+          load(packages_path,"packages","categories","categories_flat");
+          %_atoms_cache = list(packages, categories, categories_flat);
+      else
+          packages = %_atoms_cache(1);
+          categories = %_atoms_cache(2);
+          categories_flat = %_atoms_cache(3);
+      end
   end
 
 endfunction
index 253d3aa..588c4d7 100644 (file)
@@ -215,11 +215,12 @@ static std::set < string > createScilabDefaultVariablesSet()
                      "%toolboxes",
                      "%toolboxes_dir",
                      "TICTOC",
-                     "%helps_modules"
+                     "%helps_modules",
+                     "%_atoms_cache"
                    };
     int i = 0;
 
-#define NBELEMENT 31
+#define NBELEMENT 32
     std::set < string > ScilabDefaultVariables;
 
     for (i = 0; i <= NBELEMENT; i++)