Reduce memory footprint by reducing size of data types #242
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to reduce the memory footprint of using this crate.
String
types are changed toBox<str>
to save 8 bytes each.thin-vec
crate is used to replaceVec
's, saving 16 bytes each.Option
's areBox
edHashMap
s areBox
edI try to avoid making code-breaking changes, but some return types are changed, such as
&Vec<T>
to&[T]
... in most cases that shouldn't matter. The entire test suite compiles are run without change.The current API design prevents more involved optimizations without breaking code. For example, returning
&bool
,&u32
etc. prevents those fields from being replaced by smaller, packed data types likebitflags
. A future major version should really change those to return non-references instead.I have given up on optimizing chart data types because they are simply too tedious, and there shouldn't really be more than a few charts in a typical spreadsheet.