buffer: improve Buffer.from performance
Using == null in code paths that are expected to mostly receive objects, arrays or other more complex data types is not ideal because typecasting these types is very slow. Change to instead check === null || === undefined. Also move one variable assignment in fromString after an if condition that doesn't need it (and returns if truthy). PR-URL: https://github.com/nodejs/node/pull/15178 Refs: https://jsperf.com/triple-equals-vs-double-equals/3 Reviewed-By:Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By:
James M Snell <jasnell@gmail.com> Reviewed-By:
Timothy Gu <timothygu99@gmail.com>
parent
16a81cd2
Please register or sign in to comment