diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-09-04 08:53:43 -0400 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-09-11 00:05:28 -0300 |
commit | fc1fa4e2c49aa060b97b139ff02b5be8037dba94 (patch) | |
tree | 080bfd70b0b6aa8889727086335f1e9f1e65be3d /benchmark/crypto | |
parent | 16a81cd2c0478bdc4b6261b69644e05f11c90d55 (diff) | |
download | android-node-v8-fc1fa4e2c49aa060b97b139ff02b5be8037dba94.tar.gz android-node-v8-fc1fa4e2c49aa060b97b139ff02b5be8037dba94.tar.bz2 android-node-v8-fc1fa4e2c49aa060b97b139ff02b5be8037dba94.zip |
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>
Diffstat (limited to 'benchmark/crypto')
0 files changed, 0 insertions, 0 deletions