Skip to content

Commit

Permalink
lib: adding perf notes js_stream_socket.js
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
ryanj authored and targos committed Dec 1, 2019
1 parent 8a63ea1 commit ab25a82
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/js_stream_socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ab25a82

Please sign in to comment.