We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c94e80a commit 2a6ee53Copy full SHA for 2a6ee53
base/array.jl
@@ -1467,8 +1467,7 @@ For types that support `sizehint!`,
1467
"""
1468
function sizehint! end
1469
1470
-function sizehint!(a::Vector, sz::Integer)
1471
- # TODO - controll shrinkage
+function sizehint!(a::Vector, sz::Integer; shrink = true)
1472
len = length(a)
1473
ref = a.ref
1474
mem = ref.mem
@@ -1477,7 +1476,7 @@ function sizehint!(a::Vector, sz::Integer)
1477
1476
sz = max(Int(sz), offset + len - 1)
1478
if sz <= memlen
1479
# if we don't save at least 1/8th memlen then its not worth it to shrink
1480
- if memlen - sz <= div(memlen, 8)
+ if !shrink || memlen - sz <= div(memlen, 8)
1481
return a
1482
end
1483
newmem = array_new_memory(mem, sz)
0 commit comments