shithub: mc

Download patch

ref: 026ccbd147926e470ff77a5f1bc613dad7017799
parent: 894bed9a153ab56763627975f9e109281bec297b
author: Ori Bernstein <[email protected]>
date: Sat Aug 30 06:30:11 EDT 2014

Add comment to explain why slpush() is ok

        slpush relies on implementation details of slgrow for
        efficiency. Because bucket sizes come in powers of two for all
        buckets <= 32k, and we only reallocate when we hit a bucket
        boundary, this is effectively growing the slice by powers of
        two.

--- a/libstd/slpush.myr
+++ b/libstd/slpush.myr
@@ -7,6 +7,14 @@
 ;;
 
 generic slpush = {sl, elt
+	/*
+	slpush relies on implementation details
+	of slgrow for efficiency. Because bucket
+	sizes come in powers of two for all buckets
+	<= 32k, and we only reallocate when we hit
+	a bucket boundary, this is effectively
+	growing the slice by powers of two.
+	*/
 	sl = slgrow(sl, sl.len + 1)
 	sl[sl.len - 1] = elt
 	-> sl