stream: rename poorly named function
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 20 Aug 2015 20:33:12 +0000 (22:33 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 24 Aug 2015 18:24:15 +0000 (20:24 +0200)
roundUpToNextPowerOf2() does more than just rounding up to the next
power of two.  Rename it to computeNewHighWaterMark().

PR-URL: https://github.com/nodejs/node/pull/2479
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
lib/_stream_readable.js

index 766577a..681c3ea 100644 (file)
@@ -192,7 +192,7 @@ Readable.prototype.setEncoding = function(enc) {
 
 // Don't raise the hwm > 8MB
 const MAX_HWM = 0x800000;
-function roundUpToNextPowerOf2(n) {
+function computeNewHighWaterMark(n) {
   if (n >= MAX_HWM) {
     n = MAX_HWM;
   } else {
@@ -231,7 +231,7 @@ function howMuchToRead(n, state) {
   // power of 2, to prevent increasing it excessively in tiny
   // amounts.
   if (n > state.highWaterMark)
-    state.highWaterMark = roundUpToNextPowerOf2(n);
+    state.highWaterMark = computeNewHighWaterMark(n);
 
   // don't have that much.  return null, unless we've ended.
   if (n > state.length) {