mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 17:06:16 -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;
|
||||
|
|
|
@ -355,7 +355,7 @@ exports.handleCustomObjectMessage = function (msg, sessionID, cb) {
|
|||
* @param msgString {String} the message we're sending
|
||||
*/
|
||||
exports.handleCustomMessage = function (padID, msgString, cb) {
|
||||
var time = new Date().getTime();
|
||||
var time = Date.now();
|
||||
var msg = {
|
||||
type: 'COLLABROOM',
|
||||
data: {
|
||||
|
@ -375,7 +375,7 @@ exports.handleCustomMessage = function (padID, msgString, cb) {
|
|||
*/
|
||||
function handleChatMessage(client, message)
|
||||
{
|
||||
var time = new Date().getTime();
|
||||
var time = Date.now();
|
||||
var userId = sessioninfos[client.id].author;
|
||||
var text = message.data.text;
|
||||
var padId = sessioninfos[client.id].padId;
|
||||
|
@ -1313,7 +1313,7 @@ function handleClientReady(client, message)
|
|||
"numConnectedUsers": roomClients.length,
|
||||
"readOnlyId": padIds.readOnlyPadId,
|
||||
"readonly": padIds.readonly,
|
||||
"serverTimestamp": new Date().getTime(),
|
||||
"serverTimestamp": Date.now(),
|
||||
"userId": author,
|
||||
"abiwordAvailable": settings.abiwordAvailable(),
|
||||
"sofficeAvailable": settings.sofficeAvailable(),
|
||||
|
|
|
@ -204,7 +204,7 @@ function minify(req, res, next)
|
|||
res.setHeader('last-modified', date.toUTCString());
|
||||
res.setHeader('date', (new Date()).toUTCString());
|
||||
if (settings.maxAge !== undefined) {
|
||||
var expiresDate = new Date((new Date()).getTime()+settings.maxAge*1000);
|
||||
var expiresDate = new Date(Date.now()+settings.maxAge*1000);
|
||||
res.setHeader('expires', expiresDate.toUTCString());
|
||||
res.setHeader('cache-control', 'max-age=' + settings.maxAge);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue