Fix #8127 - performance issues - cache pulldowns
authorAlan <alan@roojs.com>
Fri, 5 Apr 2024 06:05:25 +0000 (14:05 +0800)
committerAlan <alan@roojs.com>
Fri, 5 Apr 2024 06:05:25 +0000 (14:05 +0800)
src/Builder4/WindowLeftProps.bjs
src/Builder4/WindowLeftProps.vala
src/JsRender/NodeProp.vala
src/Palete/Roo.vala

index 5b2cd59..d552b73 100644 (file)
          "id" : "valcol",
          "items" : [
           {
+           "# bool is_setting" : false,
            "$ xns" : "Gtk",
            "* prop" : "factory",
-           "bool is_setting" : false,
            "listeners" : {
             "bind" : [
              "(listitem) => {",
              "",
              "",
              "\tvar bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();",
-             " ",
-             "\t",
-             "\t",
+             "  ",
              "\t",
              "\tvar elbl = (Gtk.EditableLabel)bx.get_first_child();",
              "\tvar lbl = (Gtk.Label) elbl.get_next_sibling();",
index 1200d93..7c8e66d 100644 (file)
@@ -2340,9 +2340,7 @@ public class Xcls_LeftProps : Object
                        
                        
                                var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
-                        
-                               
-                               
+                         
                                
                                var elbl = (Gtk.EditableLabel)bx.get_first_child();
                                var lbl = (Gtk.Label) elbl.get_next_sibling();
index 76bd895..9bc879b 100644 (file)
@@ -468,10 +468,10 @@ public class JsRender.NodeProp : Object {
                owned get {
                        
                         if (this._val.index_of("\n") < 0) {
-                               return this._val;
+                               return  GLib.Markup.escape_text(this._val);
                         }
                         var vals = this._val.split("\n");
-                        return vals[0]  + (vals.length > 1 ? " ..." : "");
+                        return GLib.Markup.escape_text(vals[0]  + (vals.length > 1 ? " ..." : ""));
                } 
        }
  
index d05c7a1..741123d 100644 (file)
@@ -349,27 +349,34 @@ namespace Palete {
                        
 
                }
-
+       
+               Gee.HashMap<string,string> typeOptionsCache { get ;set ; default = new Gee.HashMap<string,string>(); }
                /*
                 *  Pulldown options for type
                 */
                public override bool typeOptions(string fqn, string key, string type, out string[] opts) 
                {
                        opts = {};
-                       print("get typeOptions %s (%s)%s", fqn, type, key);
+                       GLib.debug("get typeOptions %s (%s)%s", fqn, type, key);
                        if (type.up() == "BOOL" || type.up() == "BOOLEAN") {
                                opts = { "true", "false" };
                                return true;
-                        }
+                       }
+                       var cacheKey = fqn + ":"+ key;
+                        if (this.typeOptionsCache.has_key(cacheKey)) {
+                               opts = this.typeOptionsCache.get(cacheKey).split("\n");
+                               return opts.length < 1 ? false : true;
+                       }
                         
                         var props = this.getPropertiesFor(fqn, JsRender.NodePropType.PROP);
                         if (!props.has_key(key)) {
+                                this.typeOptionsCache.set(cacheKey, "");
                                 print("prop %s does not have key %s\n", fqn, key);
                                 return false;
                         }
                         var pr = props.get(key);
                         if (pr.optvalues.size < 1) {
+                                this.typeOptionsCache.set(cacheKey, "");
                                 print("prop %s no optvalues for %s\n", fqn, key);
                                 return false;
                         }
@@ -379,6 +386,7 @@ namespace Palete {
                         }
                         opts = ret;
                         print("prop %s returning optvalues for %s\n", fqn, key);
+                        this.typeOptionsCache.set(cacheKey, string.joinv("\n", ret));
                         return true;
                         
                }