aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorMCRusher <Modernwarfare3Minecraft64@gmail.com>2019-11-23 23:49:55 -0500
committerGitHub <noreply@github.com>2019-11-23 23:49:55 -0500
commit17abb7ef7f75705c1195022076e95cdde6ab2243 (patch)
treee2ac48ed25c54c6e3b13eaddb1876331cd020eec /src/codegen.cpp
parentd49e0a7b90dabbf486902fa9d4a4306aede55087 (diff)
downloadzig-17abb7ef7f75705c1195022076e95cdde6ab2243.tar.gz
zig-17abb7ef7f75705c1195022076e95cdde6ab2243.zip
Adds initCapacity() to buffer and arraylist
array_list.zig: - adds ArrayList.initCapacity(*Allocator,usize) to allow preallocation of a block at initialization to reduce future allocations. - adds a test for ArrayList.initCapacity() that ensures ArrayList.len() is unchanged and that at least the requested amount is allocated for. buffer.zig: - adds Buffer.initCapacity(*Allocator,usize), based off of ArrayList.initCapacity(), to preallocate a buffer before use. note: contrary to Buffer.initSize(0) and then Buffer.list.ensureCapacity(200) (the presumed current method), this only allocates once instead of twice. - adds Buffer.capacity to check usable allocated space, not including the null byte. note: returns 0 when Buffer has only a null byte or when initNull() was used before without resize()/replaceContents(). - adds a test "Buffer.initCapacity" which ensures that Buffer.append()'s with [added size <= Buffer.capacity()-Buffer.len()] do not cause a reallocation to occur. - adds a test "Buffer.initSize" which ensures that Buffer.initSize() behaves as expected, also combined with Buffer.append(). - adds a doc comment to Buffer.initSize() that makes its function and distinction from Buffer.initCapacity() clearer.
Diffstat (limited to 'src/codegen.cpp')
0 files changed, 0 insertions, 0 deletions