Commit 90368fb
authored
unmarshal: optimize slice capacity growth in unmarshalArray function (#87)
When unmarshaling an array from a plist file into a slice, two issues
occur related to slice capacity growth:
- Unnecessary growth: The slice grows even when the current capacity is
enough to hold all elements. Specifically, the slice grows
`if cnt >= val.Cap()`, even when the current capacity is sufficient.
- Doubling capacity: The slice's capacity is always doubled, which is
inefficient. It should follow a more dynamic growth pattern, similar
to Go's built-in slice growth algorithm.
Fixes #861 parent 8423e05 commit 90368fb
1 file changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
246 | 255 | | |
247 | 256 | | |
248 | 257 | | |
| |||
0 commit comments