mccolljr / segvec

SegVec data structure for rust. Similar to Vec, but allocates memory in chunks of increasing size.
MIT License
35 stars 5 forks source link

Faster indexing #32

Closed cehteh closed 1 year ago

cehteh commented 1 year ago

It still nagged me that indexing was somewhat slow. These patches improve indexing (and iterations as well) when the index is already checked or known to be in bounds by using unsafe .get_unchecked() variants instead Index::index(). This adds some unsafe code, thus it needs some review/consideration. I am pretty sure its all trivial and safe and the performance gain makes it reasonable.