bulk-copy fast path for List(u8, _) deserialize - #66
Conversation
| if (comptime Self.Item == u8) { | ||
| // route through deserialize's existing []u8 fast path | ||
| if (serialized.len > N) return error.OffsetExceedsSize; | ||
| try out.inner.resize(alloc, serialized.len); |
There was a problem hiding this comment.
this is tricky, because if the data isn't already allocated in the slice, then the resizing will incur a copy of everything that came before the deserialization. There are therefore cases in which allocating the data in deserialize by passing an allocator is the better move.
There was a problem hiding this comment.
copying over from TG.
out is initialized as empty. so resize will be a fresh new allocation. Also if we let deserialize do the allocation, ArrayList will be weirdly initialized. capacity field will be not set properly, no?
There was a problem hiding this comment.
so the problem was really that there is an allocation site that is optional, and because the array list has its own allocator, it was really redundant. But if you look at it, the "fast path" is to just call the @memcopy function. Might as well save a lot of clutter and just do the copy directly here. LMK what you think
No description provided.