On Sat, Sep 4, 2021 at 8:57 PM tapi...@gmail.com <tapir....@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.


>     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.

-- 
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/CABx2%3DD-_ytZbLZzSMHTro7ej%2BE4UKk7e%2BCep4Z24W5Myf47iZA%40mail.gmail.com.

Reply via email to