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:
muxator 2019-02-26 23:25:15 +01:00
parent 90bfbeb38d
commit b34fc2de2b
13 changed files with 23 additions and 23 deletions

View file

@ -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(),