fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.39k stars 110 forks source link

Copy from old bump into new bump? #97

Closed jkelleyrtp closed 3 years ago

jkelleyrtp commented 3 years ago

Is there a fast way to copy objects from one bump into another bump, beyond just cloning and allocating?

Or, would it be better to just keep a bump around for each set of objects (ie for caching)?

fitzgen commented 3 years ago

There isn't anything more optimized than https://docs.rs/bumpalo/3.6.0/bumpalo/struct.Bump.html#method.alloc_slice_copy or bump.alloc_with(|| old.clone()).

Or, would it be better to just keep a bump around for each set of objects (ie for caching)?

This depends on the application and size of the objects, locality, etc, but in general doing less (i.e. not cloning and re-allocing) should be faster.