Skip to content
Permalink
Browse files

lib: adding perf notes js_stream_socket.js

Leaving var in place of let for performance optimization
in short loops in hot paths. Added comments explaining why.

PR-URL: #30415
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
ryanj authored and MylesBorins committed Nov 12, 2019
1 parent e52237d commit 7d0631aefcbe2e862cda05a0689bba42b385ced7
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/internal/js_stream_socket.js
@@ -157,6 +157,7 @@ class JSStreamSocket extends Socket {
let pending = bufs.length;

this.stream.cork();
// Use `var` over `let` for performance optimization.
for (var i = 0; i < bufs.length; ++i)
this.stream.write(bufs[i], done);
this.stream.uncork();

0 comments on commit 7d0631a

Please sign in to comment.
You can’t perform that action at this time.