unmarshal: optimize slice capacity growth in unmarshalArray function#87
unmarshal: optimize slice capacity growth in unmarshalArray function#87DHowett merged 1 commit intoDHowett:mainfrom
Conversation
|
I should note before merging, though, that this doesn't meet the criteria you laid out in #86 - when the cap is 5, it still grows to 10 rather than 8. Is that still acceptable? |
|
If the slice has already been allocated with an underlying array (e.g., the slice capacity is 5), and the parsed elements cannot fit into the current capacity (e.g., 7 elements), then the capacity should grow by doubling (resulting in a new capacity of 10). However, if the slice has not been allocated yet (e.g., it is This is actually what I planned with these changes. |
|
Ah, perfect |
|
This is also the same as how |
fixes #86