refactor split_str_once#7483
Open
Goober5000 wants to merge 1 commit into
Open
Conversation
5b68a0e to
f901889
Compare
63128d3 to
761a111
Compare
761a111 to
ec31049
Compare
ec31049 to
f3de2f8
Compare
f3de2f8 to
56db112
Compare
Rewrite `split_str_once` to be more robust, to handle Unicode, and to return length and position information rather than modifying the source string, taking the approach also used by `str_wrap_to_width`. In combination with the new length variants of common string utility functions, this allows strings to be split without copying them. In many cases, using the old design, strings were copied multiple times per frame in numerous places. Includes unit tests to handle numerous usual and unusual cases. All of the historical string splitting anomalies should now be fixed, including a bug in the retail algorithm where an exactly matching string followed by whitespace wasn't split properly. A followup PR will refactor `split_str`.
56db112 to
7412e0b
Compare
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.
Rewrite
split_str_onceto be more robust, to handle Unicode, and to return length and position information rather than modifying the source string, taking the approach also used bystr_wrap_to_width. In combination with the new length variants of common string utility functions, this allows strings to be split without copying them. In many cases, using the old design, strings were copied multiple times per frame in numerous places.Includes unit tests to handle numerous usual and unusual cases. All of the historical string splitting anomalies should now be fixed, including a bug in the retail algorithm where an exactly matching string followed by whitespace wasn't split properly.
A followup PR will refactor
split_str.