streams: performance improvements for clearBuffer in Writable
This commits removes a function allocation inside the clearBuffer function. Moreover, it adds counting of buffered chunks to instantiate a fixed-sized Array. The performance improvements are in the range 5-50%, depending on the usecase.
Here is gist of the results of the http benchmarks in node on my MacBook Pro Late 2014 (i7, 16GB of RAM): https://gist.github.com/mcollina/5c59c057cb5b138fcd70.
cc @trevnorris @lucamaraschi @nodejs/benchmarking