Skip to content

Commit b085b94

Browse files
cjihrigtargos
authored andcommitted
console: minor timeLogImpl() refactor
This commit does two things: - Reverses the boolean value returned by timeLogImpl(). The new values make more sense semantically (IMO anyway), and save a a single NOT operation. - Explicitly check for undefined when calling _times.get() instead of coercing the value. PR-URL: #29100 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 31c50e5 commit b085b94

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎lib/internal/console/constructor.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ const consoleMethods ={
310310
timeEnd(label='default'){
311311
// Coerces everything other than Symbol to a string
312312
label=`${label}`;
313-
consthasWarned=timeLogImpl(this,'timeEnd',label);
313+
constfound=timeLogImpl(this,'timeEnd',label);
314314
trace(kTraceEnd,kTraceConsoleCategory,`time::${label}`,0);
315-
if(!hasWarned){
315+
if(found){
316316
this._times.delete(label);
317317
}
318318
},
@@ -509,12 +509,12 @@ const consoleMethods ={
509509
},
510510
};
511511

512-
// Returns true if label was not found
512+
// Returns true if label was found
513513
functiontimeLogImpl(self,name,label,data){
514514
consttime=self._times.get(label);
515-
if(!time){
515+
if(time===undefined){
516516
process.emitWarning(`No such label '${label}' for console.${name}()`);
517-
returntrue;
517+
returnfalse;
518518
}
519519
constduration=process.hrtime(time);
520520
constms=duration[0]*1000+duration[1]/1e6;
@@ -523,7 +523,7 @@ function timeLogImpl(self, name, label, data){
523523
}else{
524524
self.log('%s: %sms',label,ms.toFixed(3), ...data);
525525
}
526-
returnfalse;
526+
returntrue;
527527
}
528528

529529
constkeyKey='Key';

0 commit comments

Comments
(0)