I changed some fields' types of the CellType enum from String to Box<str> or Rc<str>. Result:
Before
After
Size (Bytes)
80
56
Alignment
8
6
This improves cache locality and allows the compiler to better optimize its use.
I also refactored the prepare_formula function because I needed it to output a Box<str> instead of a String.
Why Rc<str>?
To improve the performance of the shared_string_index function. This is a hot function that needs to clone strings some of the time. By using Rc<str> the clones become really cheap.
CellType
enum fromString
toBox<str>
orRc<str>
. Result:This improves cache locality and allows the compiler to better optimize its use.
I also refactored the
prepare_formula
function because I needed it to output aBox<str>
instead of aString
.Why
Rc<str>
?To improve the performance of the
shared_string_index
function. This is a hot function that needs to clone strings some of the time. By usingRc<str>
the clones become really cheap.