Nice! Arnaud
On Tue, 7 Sep 2021, 18:02 Keith Randall, <k...@google.com> wrote: > Sounds good. CL up for review at > https://go-review.googlesource.com/c/go/+/347917 > > On Mon, Sep 6, 2021 at 7:30 PM Arnaud Delobelle <arno...@gmail.com> wrote: > >> If the growing function is currently >> >> f(x) = 2x for x < 1024 >> f(x) = x + x/4 otherwise >> >> (Which I haven't checked), couldn't a simple way be to use e.g. >> >> f(x) = 2x for x < 1024 >> f(x) = x + x/4 + 768 otherwise >> >> Then >> >> f(1023) = 2046 >> f(1024) = 2048 >> >> So the function is monotonic (and kind of "smooth") >> >> On Tue, 7 Sep 2021, 02:17 'Keith Randall' via golang-nuts, < >> golang-nuts@googlegroups.com> wrote: >> >>> I don't think this is an important thing to fix, but I agree it is a bit >>> odd. If there's a simple way to restore monotonicity we'll consider it. >>> A similar issue: https://github.com/golang/go/issues/41239 >>> >>> On Sunday, September 5, 2021 at 8:59:01 AM UTC-7 jake...@gmail.com >>> wrote: >>> >>>> You are 100% correct. I missed that value. oops >>>> >>>> On Sunday, September 5, 2021 at 10:16:08 AM UTC-4 arn...@gmail.com >>>> wrote: >>>> >>>>> >>>>> >>>>> On Sun, 5 Sep 2021, 14:59 jake...@gmail.com, <jake...@gmail.com> >>>>> wrote: >>>>> [...] >>>>> >>>>>> In the example given (https://play.golang.org/p/RJbEkmFsPKM >>>>>> <https://play.golang.org/p/RJbEkmFsPKM>), the capacities *are >>>>>> *"monotonically >>>>>> increasing", as no number in the second column is smaller than the one >>>>>> before it. >>>>>> >>>>> >>>>> Nitpick: that is not true. I copy-pasted the output of the playground >>>>> below. >>>>> >>>>> 0 8 >>>>> 100 208 >>>>> 200 416 >>>>> 300 640 >>>>> 400 896 >>>>> 500 1024 >>>>> 600 1280 >>>>> 700 1408 >>>>> 800 1792 >>>>> 900 2048 >>>>> 1000 2048 >>>>> 1100 1408 <-- at this point the new cap is less than for the previous >>>>> row >>>>> 1200 1536 >>>>> 1300 1792 >>>>> 1400 1792 >>>>> 1500 2048 >>>>> 1600 2048 >>>>> 1700 2304 >>>>> 1800 2304 >>>>> 1900 2688 >>>>> >>>>> Regards, >>>>> >>>>> Arnaud >>>>> >>>>> On Sunday, September 5, 2021 at 7:02:43 AM UTC-4 kortschak wrote: >>>>>> >>>>>>> On Sun, 2021-09-05 at 03:51 -0700, Brian Candler wrote: >>>>>>> > I'm not sure you're clear about what "monotonically increasing" >>>>>>> > means. >>>>>>> > >>>>>>> > Are you saying that there are some cases where append() results in >>>>>>> > the allocated size of a slice *shrinking*? If so, please >>>>>>> > demonstrate. >>>>>>> >>>>>>> I think he means that the cap of the appended slice is not a >>>>>>> monotonically increasing function of the cap of the input slice. >>>>>>> >>>>>>> https://play.golang.org/p/RJbEkmFsPKM >>>>>>> >>>>>>> >>>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "golang-nuts" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to golang-nuts...@googlegroups.com. >>>>>> >>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/golang-nuts/912453d5-2f2f-43b2-b65f-ce27e95752e9n%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/golang-nuts/912453d5-2f2f-43b2-b65f-ce27e95752e9n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to golang-nuts+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/fa360f3d-e23c-4c07-9505-9f89bd155bb8n%40googlegroups.com >>> <https://groups.google.com/d/msgid/golang-nuts/fa360f3d-e23c-4c07-9505-9f89bd155bb8n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJ6cK1aAonAjO7rd8-wnnVeLAFX4HixFUk7s3hJnEqtwRaz4uA%40mail.gmail.com.