Add IO
overloads to Char#upcase
, #downcase
, #titlecase
#15508
+98
−24
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.
These additions mirror
String#upcase
,#downcase
, and#capitalize
respectively, which also have overloads that accept anIO
.There is a more technical reason for this PR. Case conversion methods in
String
are among the largest functions in the standard library when measured by the number of lines of LLVM IR;#underscore
measures 4.2k lines,#camelcase
1.9k lines, and#titleize
1.4k lines. This is due to inlining of the multiple{ |c| io << c }
blocks, which go all the way down to the body of e.g.Unicode.downcase(char : Char, options : CaseOptions, &)
. By establishing an inlining boundary, those line counts are now 0.67k, 0.23k, and 0.25k, whereas the newChar
methods themselves contribute another 0.75k lines total.