shithub: mc

Download patch

ref: 83c62e5ed5a9d1cf16d418e7b54391074bf38918
parent: c694d9a9c3f8c78837cf3bcbbe11fb19d04c204d
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Jan 20 17:17:52 EST 2016

Don't grow the buffer for every read.

	Some things, like pipe buffers, will eventually cap out
	at a certain size. Only grow the buffer if we couldn't do
	another read twice the size of the last one.

--- a/lib/std/slurp.myr
+++ b/lib/std/slurp.myr
@@ -37,8 +37,10 @@
 			-> `Ok buf[:len]
 		| `Ok n:
 			len += n
-			bufsz *= 2
-			buf = slgrow(buf, bufsz)
+			if len + 2*n >= bufsz
+				bufsz *= 2
+				buf = slgrow(buf, bufsz)
+			;;
 		| `Fail e:
 			-> `Fail e
 		;;