ref: 094074d7ecb008cd3d59dd0d011387299a9fe9c8
parent: 4ef5e4ab736c4c5e083654daedfd6ba32e112d51
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