maintaining basic_string performance with vector by adding sso implementation#326
Merged
maintaining basic_string performance with vector by adding sso implementation#326
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#325 is fine for tackling with basic_string not being available on clang on some envs...but it's temp, cause that's gonna become a standard.
basic_string is bad to lose in favor of vector because it provides an important performance optimization - sso. sso, is basically just saying that in small enough strings/vectors use a stack allocated array instead of heap allocated memory. fine...so this PR implements and alternative implementation for vector to be used as part of bytelist for when the sizes are small (<22).
the implementation a bit verbose, but not too complicated - ByteList is now a class implementing all methods used by the repo for basic_string. It then either forward to its vector based implementation or to its static array implementation. using array to make it read less complex....though it does mean a lot of forwarding for the basic vector.
not the prettiest work, but efficient (meaning - gets good performance, as far as i can tell), and should be fairly stable (meaning, using high level function of vector, so don't expect trouble there, and the array implementation is kinda simple).
used copilot plugin to speed this up, but made sure the code looks half decent :).