mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
use Date.now() instead of new Date().getTime()
This is documented to be more performant. The substitution was made on frontend code, too (i.e., the one in /static), because Date.now() is supported since IE 9, and we are life supporting only IE 11. Commands: find . -name *.js | xargs sed --in-place "s/new Date().getTime()/Date.now()/g" find . -name *.js | xargs sed --in-place "s/(new Date()).getTime()/Date.now()/g" Not done on jQuery.
This commit is contained in:
parent
90bfbeb38d
commit
b34fc2de2b
13 changed files with 23 additions and 23 deletions
|
@ -522,7 +522,7 @@ exports.appendChatMessage = function(padID, text, authorID, time, callback)
|
|||
if(time === undefined || !is_int(time))
|
||||
{
|
||||
// set time to current timestamp
|
||||
time = new Date().getTime();
|
||||
time = Date.now();
|
||||
}
|
||||
|
||||
var padMessage = require("ep_etherpad-lite/node/handler/PadMessageHandler.js");
|
||||
|
|
|
@ -110,7 +110,7 @@ function mapAuthorWithDBKey (mapperkey, mapper, callback)
|
|||
|
||||
//there is a author with this mapper
|
||||
//update the timestamp of this author
|
||||
db.setSub("globalAuthor:" + author, ["timestamp"], new Date().getTime());
|
||||
db.setSub("globalAuthor:" + author, ["timestamp"], Date.now());
|
||||
|
||||
//return the author
|
||||
callback(null, {authorID: author});
|
||||
|
@ -127,7 +127,7 @@ exports.createAuthor = function(name, callback)
|
|||
var author = "a." + randomString(16);
|
||||
|
||||
//create the globalAuthors db entry
|
||||
var authorObj = {"colorId" : Math.floor(Math.random()*(exports.getColorPalette().length)), "name": name, "timestamp": new Date().getTime()};
|
||||
var authorObj = {"colorId" : Math.floor(Math.random()*(exports.getColorPalette().length)), "name": name, "timestamp": Date.now()};
|
||||
|
||||
//set the global author db entry
|
||||
db.set("globalAuthor:" + author, authorObj);
|
||||
|
|
|
@ -86,7 +86,7 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
|
|||
newRevData.changeset = aChangeset;
|
||||
newRevData.meta = {};
|
||||
newRevData.meta.author = author;
|
||||
newRevData.meta.timestamp = new Date().getTime();
|
||||
newRevData.meta.timestamp = Date.now();
|
||||
|
||||
//ex. getNumForAuthor
|
||||
if(author != '')
|
||||
|
@ -739,7 +739,7 @@ Pad.prototype.addSavedRevision = function addSavedRevision(revNum, savedById, la
|
|||
savedRevision.revNum = revNum;
|
||||
savedRevision.savedById = savedById;
|
||||
savedRevision.label = label || "Revision " + revNum;
|
||||
savedRevision.timestamp = new Date().getTime();
|
||||
savedRevision.timestamp = Date.now();
|
||||
savedRevision.id = randomString(10);
|
||||
|
||||
//save this new saved revision
|
||||
|
|
|
@ -152,7 +152,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
|
|||
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
var now = Math.floor(new Date().getTime()/1000);
|
||||
var now = Math.floor(Date.now()/1000);
|
||||
|
||||
//is it for this group?
|
||||
if(sessionInfo.groupID != groupID)
|
||||
|
|
|
@ -114,7 +114,7 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
}
|
||||
|
||||
//check if validUntil is in the future
|
||||
if(Math.floor(new Date().getTime()/1000) > validUntil)
|
||||
if(Math.floor(Date.now()/1000) > validUntil)
|
||||
{
|
||||
callback(new customError("validUntil is in the past","apierror"));
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue