myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r982179 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_Lang.js core/Impl.js
Date Wed, 04 Aug 2010 09:40:30 GMT
Author: werpu
Date: Wed Aug  4 09:40:30 2010
New Revision: 982179

URL: http://svn.apache.org/viewvc?rev=982179&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2855

Changing the this and all replacement code in favor of an index map approach the performance
for small lists should be more or less the same but it has performance benefits in bigger
lists and also allows a clean approach if we have to follow mojarras behavior

Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=982179&r1=982178&r2=982179&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
(original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
Wed Aug  4 09:40:30 2010
@@ -350,6 +350,19 @@ myfaces._impl.core._Runtime.singletonDel
     }
     ,
 
+
+    arrToMap: function(arr, offset) {
+        var ret = new Array(arr.length);
+        var len = arr.length;
+        offset = (offset)? offset: 0;
+
+        for (var cnt = 0; cnt < len; cnt++) {
+            ret[arr[cnt]] = cnt+offset;
+        }
+
+        return ret;
+    },
+
     /**
      * Concatenates an array to a string
      * @param {Array} arr the array to be concatenated
@@ -370,10 +383,8 @@ myfaces._impl.core._Runtime.singletonDel
 
         delimiter = delimiter || "\n";
         return arr.join(delimiter);
-    },
-
-
-
+    }
+    ,
 
 
     objToArray: function(obj, offset, pack) {
@@ -398,7 +409,8 @@ myfaces._impl.core._Runtime.singletonDel
             return finalPack;
         }
 
-    },
+    }
+    ,
 
     /**
      * foreach implementation utilizing the
@@ -431,7 +443,8 @@ myfaces._impl.core._Runtime.singletonDel
                 }
             }
         }
-    },
+    }
+    ,
 
 
     /**
@@ -470,7 +483,8 @@ myfaces._impl.core._Runtime.singletonDel
                 }
             }
         }
-    },
+    }
+    ,
 
     /**
      * adds a EcmaScript optimized indexOf to our mix,
@@ -500,7 +514,8 @@ myfaces._impl.core._Runtime.singletonDel
             pos++;
         }
         return (pos < len) ? pos : -1;
-    },
+    }
+    ,
 
 
     /**
@@ -532,7 +547,8 @@ myfaces._impl.core._Runtime.singletonDel
                 }
             }
         }
-    },
+    }
+    ,
     /**
      * creates a standardized error message which can be reused by the system
      *
@@ -554,7 +570,8 @@ myfaces._impl.core._Runtime.singletonDel
             ret.push(this.keyValToStr("Error line number: ", 'undefined' != typeof error.lineNumber
? error.lineNumber : "undefined"));
         }
         return ret.join("");
-    },
+    }
+    ,
 
     /**
      * transforms a key value pair into a string
@@ -571,7 +588,8 @@ myfaces._impl.core._Runtime.singletonDel
         }
         ret.push(delimiter);
         return ret.join("");
-    },
+    }
+    ,
 
 
     parseXML: function(txt) {
@@ -587,13 +605,15 @@ myfaces._impl.core._Runtime.singletonDel
             xmlDoc.loadXML(txt);
         }
         return xmlDoc;
-    },
+    }
+    ,
 
     serializeXML: function(xmlNode) {
         if (xmlNode.xml) return xmlNode.xml; //IE
         //rest of the world
         return (new XMLSerializer()).serializeToString(xmlNode);
-    },
+    }
+    ,
 
     serializeChilds: function(xmlNode) {
         var buffer = [];
@@ -602,7 +622,8 @@ myfaces._impl.core._Runtime.singletonDel
             buffer.push(this.serializeXML(xmlNode.childNodes[cnt]));
         }
         return buffer.join("");
-    },
+    }
+    ,
     isXMLParseError: function(xmlContent) {
         var findParseError = function(node) {
             if (!node || !node.childNodes) return false;
@@ -616,7 +637,8 @@ myfaces._impl.core._Runtime.singletonDel
                 (this.exists(xmlContent, "parseError.errorCode") && xmlContent.parseError.errorCode
!= 0) ||
                 findParseError(xmlContent)
 
-    },
+    }
+    ,
     /**
      * creates a neutral form data wrapper over an existing form Data element
      * the wrapper delegates following methods, append
@@ -674,6 +696,5 @@ myfaces._impl.core._Runtime.singletonDel
 
         return bufInstance;
     }
-
-
-});
+})
+        ;

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=982179&r1=982178&r2=982179&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
(original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
Wed Aug  4 09:40:30 2010
@@ -95,7 +95,7 @@ myfaces._impl.core._Runtime.singletonExt
         }
 
         var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
-        
+
         var ret = this._Lang.createFormDataDecorator([]);
         ajaxUtils.encodeSubmittableFields(ret, null, null, form, null);
         return ret.makeFinal();
@@ -209,7 +209,39 @@ myfaces._impl.core._Runtime.singletonExt
         passThrgh[this.P_AJAX] = true;
 
         var _this = this;
-        var transformList = function(target, srcList) {
+        var transformList = function(target, srcStr, appendIdentifier) {
+
+            //this is probably the fastest transformation method
+            //it uses an array and an index to position all elements correctly
+            //the offset variable is there to prevent 0 which results in a javascript
+            //false
+            var offset = 1;
+            var vals = (srcStr) ? srcStr.split(/\s+/) : [];
+            var idIdx = (vals.length) ? _Lang.arrToMap(vals,offset) : {};
+
+
+            if (!idIdx[_this.IDENT_NONE] && !idIdx[_this.IDENT_ALL]) {
+                if (idIdx[_this.IDENT_FORM]) {
+                    vals[idIdx[form.id]-offset] = form.id;
+                }
+                if (idIdx[_this.IDENT_THIS] && !idIdx[elementId]) {
+                    vals[idIdx[_this.IDENT_THIS]-offset] = elementId;
+                }
+                
+                //this has yet to be cleared up within the open list
+                //
+                //if (appendIdentifier && !idIdx[_this.IDENT_THIS] && !idIdx[elementId])
{
+                //    vals.push(elementId);
+                //}
+
+                passThrgh[target] = vals.join(" ");
+            } else if (all) {
+                passThrgh[target] = _this.IDENT_ALL;
+            }
+        };
+
+
+       /* var transformList = function(target, srcList) {
             var opList = _Lang.arrToString(srcList, ' '),
                     none = opList.indexOf(_this.IDENT_NONE) != -1,
                     all = opList.indexOf(_this.IDENT_ALL) != -1;
@@ -221,11 +253,11 @@ myfaces._impl.core._Runtime.singletonExt
             } else if (all) {
                 passThrgh[target] = _this.IDENT_ALL;
             }
-        };
+        };*/
 
         if (passThrgh.execute) {
             /*the options must be a blank delimited list of strings*/
-            transformList(this.P_EXECUTE, passThrgh.execute);
+            transformList(this.P_EXECUTE, passThrgh.execute, true);
             passThrgh.execute = null;
             /*remap just in case we have a valid pointer to an existing object*/
             delete passThrgh.execute;
@@ -234,7 +266,7 @@ myfaces._impl.core._Runtime.singletonExt
         }
 
         if (passThrgh.render) {
-            transformList(this.P_RENDER, passThrgh.render);
+            transformList(this.P_RENDER, passThrgh.render, false);
             passThrgh.render = null;
             delete passThrgh.render;
         }



Mime
View raw message