Commit 1c6e014b authored by Ben Noordhuis's avatar Ben Noordhuis Committed by Jeremiah Senkpiel
Browse files

stream: micro-optimize high water mark calculation

Don't iterate over all 32 bits, use some hacker's delight bit twiddling
to compute the next power of two.

The logic can be reduced to `n = 1 << 32 - Math.clz32(n)` but then it
can't easily be backported to v2.x; Math.clz32() was added in V8 4.3.

PR-URL: https://github.com/nodejs/node/pull/2479


Reviewed-By: default avatarChris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: default avatarSakthipriyan Vairamani <thechargingvolcano@gmail.com>
parent f1f4b4c4
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment