jmcnamara / rust_xlsxwriter

A Rust library for creating Excel XLSX files.
https://crates.io/crates/rust_xlsxwriter
Apache License 2.0
353 stars 25 forks source link

Minify `CellType` #27

Closed adriandelgado closed 1 year ago

adriandelgado commented 1 year ago
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.

image

jmcnamara commented 1 year ago

Looks good. Merged. Thanks.