Compare commits

...

5 Commits

Author SHA1 Message Date
Claude Bot
08d0f21ef4 docs: Fix incorrect claim about cache line optimization
Bun's fork actually REMOVED the upstream cache line optimization,
replacing it with a simpler 'capacity + capacity/2 + 8' growth algorithm.
The previous documentation incorrectly claimed Bun added cache line optimization.
2025-07-30 21:25:01 +00:00
Claude Bot
f790780b96 docs: Remove all subjective claims from fork documentation
Remove claims about performance, security, efficiency, and other benefits.
Focus purely on describing what was added or changed without making
value judgments about why those changes are beneficial.
2025-07-30 21:22:42 +00:00
Claude Bot
66c018c698 docs: Remove subjective claims from zero() method documentation
Focus on what the function does rather than why it should be used.
Remove context-dependent claims about efficiency, security, and use cases.
2025-07-30 21:21:41 +00:00
Claude Bot
76bf2a6ac0 fix: Remove trailing whitespace from documentation 2025-07-30 21:17:02 +00:00
Claude Bot
229f3dfaf3 docs: Add comprehensive documentation for MultiArrayList fork
Document Bun's fork of Zig's stdlib MultiArrayList, explaining:

- Memory safety improvements with CheckedAllocPtr tracking
- Zero initialization method for security and deterministic behavior
- Enhanced growth strategy optimized for Bun's usage patterns
- Additional API methods for memory tracking and batch operations

The documentation maintains clarity on why the fork was necessary
while preserving full API compatibility with upstream.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 21:13:58 +00:00

View File

@@ -9,6 +9,28 @@
/// for the array of each field. From the slice you can call
/// `.items(.<field_name>)` to obtain a slice of field values.
/// For unions you can call `.items(.tags)` or `.items(.data)`.
///
/// ## Bun's Fork
///
/// This is a fork of Zig's standard library MultiArrayList with the following modifications:
///
/// ### 1. Memory Safety & Debugging (`CheckedAllocPtr`)
/// - Added `alloc_ptr` field to track which allocator was used for allocation
/// - Provides runtime verification that the same allocator is used for deallocation
///
/// ### 2. Zero Initialization (`.zero()` method)
/// - Added `zero()` method that zero-initializes all allocated memory
/// - Uses `@memset(self.allocatedBytes(), 0)` to clear the entire backing buffer
///
/// ### 3. Simplified Growth Strategy
/// - Simplified capacity growth algorithm to `capacity + capacity/2 + 8`
/// - Removed upstream's cache line optimization calculations
///
/// ### 4. API Enhancements
/// - Added `memoryCost()` method for memory usage tracking
/// - Enhanced `appendListAssumeCapacity()` for batch operations
///
/// These changes maintain full API compatibility with upstream.
pub fn MultiArrayList(comptime T: type) type {
return struct {
bytes: [*]align(@alignOf(T)) u8 = undefined,
@@ -574,6 +596,11 @@ pub fn MultiArrayList(comptime T: type) type {
return capacityInBytes(self.capacity);
}
/// Zero-initialize all allocated memory in the MultiArrayList.
///
/// Sets all bytes in the backing buffer to zero, which zero-initializes all fields
/// across all elements in the list. This operation affects the entire allocated
/// capacity, not just the current length.
pub fn zero(self: Self) void {
@memset(self.allocatedBytes(), 0);
}