nskinkel / libredsalt

2 stars 1 forks source link

Avoid excessive heap allocations #29

Open nskinkel opened 9 years ago

nskinkel commented 9 years ago

Currently, when we call something like crypto::cbox::cbox, we do the following heap allocations:

We could cut this down to a single allocation for these sorts of functions, a single vector for the ciphertext output, by using some custom types. The idea is that we could wrap a vector that already has the padding allocated, then just let people use that type like a normal vector, hiding the zero-padding internally.

Two new types we could use for this would be:

(final names TBD)

We'd need to basically emulate the standard vector interface, and make sure to have functions like as_slice() and as_slice_mut() so people can pass them into e.g. file reading functions without any extra overhead.