abe8b1e0a8
This PR adds the optional `limit` parameter on String.prototype.split uses. > If provided, splits the string at each occurrence of the specified separator, but stops when limit entries have been placed in the array. Any leftover text is not included in the array at all. [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split#syntax) While the performance gain may not be significant for small texts, it can be huge for large ones. I made a benchmark on the following repository : https://github.com/Yovach/benchmark-nodejs On my machine, I get the following results: `node index.js` > normal 1: 570.092ms > normal 50: 2.284s > normal 100: 3.543s `node index-optimized.js` > optmized 1: 644.301ms > optmized 50: 929.39ms > optmized 100: 1.020s The "benchmarks" numbers are : - "lorem-1" file contains 1 paragraph of "lorem ipsum" - "lorem-50" file contains 50 paragraphes of "lorem ipsum" - "lorem-100" file contains 100 paragraphes of "lorem ipsum" |
||
---|---|---|
.. | ||
app | ||
test |