On Sunday, September 5, 2021 at 12:12:46 AM UTC-4 Kurtis Rader wrote:
> On Sat, Sep 4, 2021 at 8:57 PM tapi...@gmail.com <tapi...@gmail.com> > wrote: > >> On Saturday, September 4, 2021 at 11:50:17 PM UTC-4 Kurtis Rader wrote: >> >>> On Sat, Sep 4, 2021 at 8:39 PM tapi...@gmail.com <tapi...@gmail.com> >>> wrote: >>> >>>> The problem of the current algorithm is it is not monotonically >>>> increasing: >>>> >>> >>> Please explain why that is a problem. Also, I think you are >>> misusing "monotonically increasing". The behavior up to length 1024 is not >>> "monotonically increasing". It is exponential growth. >>> >> >> I mean the whole length range. Why would you seect [0, 1023]? >> I never deny it is exponential growth. >> > > Okay, I agree that technically your use of "monotonically increasing" does > not preclude exponential growth. However, your contrasting the behavior > around the pivot point of 1024 implies that exponential growth is excluded > since the growth is exponential on each side of the pivot point and you > stated it was "monotonically increasing" on one side but not the other. > My opinions include: 1. there should not be a slip in the whole number range. 2. the increasing should totally depend on the sum length of the two arguments. > > >> x1 := make([]int, 897) >>>> x2 := make([]int, 1024) >>>> y := make([]int, 100) >>>> println(cap(append(x1, y...))) // 2048 >>>> println(cap(append(x2, y...))) // 1280 >>>> >>>> And it is not symmetrical: >>>> >>> >>> Again, please explain why this is a problem. >>> >> >> When I merge two slices, I expect the argument orders are not important. >> > > Why? That is an undocumented implementation detail. Furthermore, the > length of "x1" and "x2" at the time when they are appended to, in > combination with the value being appended, are reasonable predictors of the > capacity of the new slice. It is up to you to prove that a different > heuristic performs better. > Are there some evidences to prove the current algorithm is better? > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- 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/1b4a000d-a71b-4d89-b509-9201b81ba547n%40googlegroups.com.