3 ms·
Giving different views and projections on underlying memory is really the key tactic to processing data without allocations. A slice (ie a view onto an array) i
by kitd 7y ago
Giving different views and projections on underlying memory is really the key tactic to processing data without allocations. A slice (ie a view onto an array) is a pointer to underlying memory (or another slice), along with the length (+ capacity in Go, but that's not often needed). Underneath the bytes don't move. You simply pass around the views (or views of views) of what you want your code to actually see.
Don't know about Rust, but Go has slices built into the language, and C++ has it in the standard library. Learning idiomatic slice-handling makes working with data sans allocation much, much easier.
- monocasa 7y ago> Don't know about Rust, but Go has slices built into the language, and C++ has it in the standard library. Rust also is very big into slices as well.