]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
perf: use faster form of copying dates, across the board improvement
authorBrian Wyant <wyantb@gmail.com>
Sat, 9 May 2015 17:40:32 +0000 (13:40 -0400)
committerIskren Chernev <iskren.chernev@gmail.com>
Mon, 13 Jul 2015 00:00:30 +0000 (17:00 -0700)
Reference: http://jsperf.com/date-copy-constructor/3

src/lib/moment/constructor.js

index f7355939305926c0fa80f7f4c0efef71fbe20ef9..b29b3d7e128466dd3607bc1aa1fc6fcaf1cc62a1 100644 (file)
@@ -58,7 +58,7 @@ var updateInProgress = false;
 // Moment prototype object
 export function Moment(config) {
     copyConfig(this, config);
-    this._d = new Date(+config._d);
+    this._d = new Date(config._d.getTime());
     // Prevent infinite loop in case updateOffset creates new moment
     // objects.
     if (updateInProgress === false) {