]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
moar speed
authorIsaac Cambron <isaac@isaaccambron.com>
Mon, 21 Jul 2014 05:22:34 +0000 (01:22 -0400)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 30 Jul 2014 05:30:42 +0000 (22:30 -0700)
.gitignore
Gruntfile.js
benchmarks/results.json [deleted file]
moment.js

index 5794af7890413fbcf90fc18031e21ecd9add54ae..5a540d3cf08abfc7ce4a4dce564f956af3b2fc7e 100644 (file)
@@ -6,4 +6,3 @@ min/tests.js
 sauce_connect.log
 .sauce-labs.creds
 npm-debug.log
-benchmarks/results.csv
index 7b49a3827396dc70c20dccd804d80fe9d4643395..943e749489b45c36e9038d998f1ab1e5f292e44f 100644 (file)
@@ -188,10 +188,9 @@ module.exports = function (grunt) {
             targetLocales: embedLocaleSrc
         },
         benchmark: {
-          all: {
-            src: ['benchmarks/*.js'],
-            dest: 'benchmarks/results.json',
-          }
+            all: {
+                src: ['benchmarks/*.js']
+            }
         }
     });
 
diff --git a/benchmarks/results.json b/benchmarks/results.json
deleted file mode 100644 (file)
index b3f7aaf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-[
-  {
-    "name": "clone",
-    "timestamp": "Sun Jul 20 2014 23:14:34 GMT-0400 (EDT)",
-    "count": 1925,
-    "cycles": 3,
-    "hz": 34836.98543958899
-  },
-  {
-    "name": "clone",
-    "timestamp": "Sun Jul 20 2014 23:21:33 GMT-0400 (EDT)",
-    "count": 1885,
-    "cycles": 8,
-    "hz": 36659.44586569106
-  },
-  {
-    "name": "clone",
-    "timestamp": "Mon Jul 21 2014 00:50:03 GMT-0400 (EDT)",
-    "count": 11378,
-    "cycles": 4,
-    "hz": 210942.42334154248
-  }
-]
\ No newline at end of file
index 4afc67b06b038be9eab2dfad02b844978436983f..1278b511f8dcd052b914e4925794a3ba46164408 100644 (file)
--- a/moment.js
+++ b/moment.js
         // internal storage for locale config files
         locales = {},
 
-        // moment internal properties
-        momentProperties = [
-          '_isAMomentObject',
-          '_i',
-          '_f',
-          '_l',
-          '_strict',
-          '_tzm',
-          '_isUTC',
-          '_offset',
-          '_pf',
-          '_locale'
-        ];
+        // extra moment internal properties (plugins register props here)
+        momentProperties = [],
 
         // check for nodeJS
         hasModule = (typeof module !== 'undefined' && module.exports),
 
     // Moment prototype object
     function Moment(config, skipOverflow) {
-        if (skipOverflow != false) {
-          checkOverflow(config);
+        if (skipOverflow !== false) {
+            checkOverflow(config);
         }
         copyConfig(this, config);
+        this._d = new Date(+config._d);
     }
 
     // Duration Constructor
     function copyConfig(to, from) {
         var i, prop, val;
 
-        for (i in momentProperties) {
-          prop = momentProperties[i];
-          val = from[prop];
-          if (typeof val !== 'undefined') {
-            to[prop] = val;
-          }
+        if (typeof from._isAMomentObject !== 'undefined') {
+            to._isAMomentObject = from._isAMomentObject;
+        }
+        if (typeof from._i !== 'undefined') {
+            to._i = from._i;
+        }
+        if (typeof from._f !== 'undefined') {
+            to._f = from._f;
+        }
+        if (typeof from._l !== 'undefined') {
+            to._l = from._l;
+        }
+        if (typeof from._strict !== 'undefined') {
+            to._strict = from._strict;
+        }
+        if (typeof from._tzm !== 'undefined') {
+            to._tzm = from._tzm;
+        }
+        if (typeof from._isUTC !== 'undefined') {
+            to._isUTC = from._isUTC;
+        }
+        if (typeof from._offset !== 'undefined') {
+            to._offset = from._offset;
+        }
+        if (typeof from._pf !== 'undefined') {
+            to._pf = from._pf;
+        }
+        if (typeof from._locale !== 'undefined') {
+            to._locale = from._locale;
         }
 
-        to._d = new Date(+from._d);
+        if (momentProperties.length > 0) {
+            for (i in momentProperties) {
+                prop = momentProperties[i];
+                val = from[prop];
+                if (typeof val !== 'undefined') {
+                    to[prop] = val;
+                }
+            }
+        }
 
         return to;
     }
 
         for (i = 0; i < config._f.length; i++) {
             currentScore = 0;
-            tempConfig = extend({}, config);
+            tempConfig = copyConfig({}, config);
             tempConfig._pf = defaultParsingFlags();
             tempConfig._f = config._f[i];
             makeDateFromStringAndFormat(tempConfig);
 
         if (moment.isMoment(input)) {
             return new Moment(input, true);
-
         } else if (format) {
             if (isArray(format)) {
                 makeDateFromStringAndArray(config);