-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
std.ArrayList: actaully memset to undefined in shrinkRetainingCapacity and clearRetainingCapacity #25832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.ArrayList: actaully memset to undefined in shrinkRetainingCapacity and clearRetainingCapacity #25832
Conversation
squeek502
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I jumped the gun on merging #25810 for a number of reasons.
The @memsets should also be added to shrinkRetainingCapacity and clearRetainingCapacity in Aligned too; right now they are only in AlignedManaged.
…y and clearRetainingCapacity See ziglang#25810
c406505 to
75e4034
Compare
|
@squeek502 updated |
|
Double checked that it behaves as expected with this code and some printing in const std = @import("std");
pub fn main() !void {
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena_state.deinit();
const arena = arena_state.allocator();
// a few more bytes than we're going to populate so there's
// some undefined bytes remaining after the initial append
var list: std.ArrayList(u8) = try .initCapacity(arena, 30);
try list.appendSlice(arena, "abcdefghijklmnopqrstuvwxyz");
std.debug.dumpHex(list.allocatedSlice());
list.shrinkRetainingCapacity(8);
std.debug.dumpHex(list.allocatedSlice());
list.clearRetainingCapacity();
std.debug.dumpHex(list.allocatedSlice());
}Performance data points: Compiler built in Debug mode with the self-hosted x86_64 backend compiling hello world: Compiler built in Debug mode with the LLVM backend compiling hello world: Standard library tests built in Debug mode with the self-hosted x86_64 backend: Standard library tests built in Debug mode with the LLVM backend: |
…ist. After ziglang#25832 it has safetey features (memset to undefined), we can take use of that here, since scratch is a temporary storage.
…ist. After ziglang#25832 it has safety features (memset to undefined), we can take use of that here, since scratch is a temporary storage.
After ziglang#25832 it has safety features (memset to undefined), we can take use of that here, since scratch is a temporary storage.
After ziglang#25832 it has safety features (memset to undefined), we can take use of that here, since scratch is a temporary storage.
See #25810