Merge byUTF inner overloads to reduce template instantiations - #11092
Merge byUTF inner overloads to reduce template instantiations#11092LightBender wants to merge 1 commit into
Conversation
|
This adds more generated code. Instead of wrapping the same implementation with 2 entry points, it reimplements the same function with a small change at the front. It also does not reduce the number of templates used. |
MethodCompared parent
Caveat: Generated code (the bloat metric)
Object size is the better bloat signal. The slightly smaller vtemplate log (327 KB → 321 KB) is a red herring: fewer tiny trampoline listings, more generated methods. Template instantiationsOuter Inner
Old full-impl instances were mostly New instances include those same autodecodable types as full-function instantiations: Driver
Same call sites, more distinct return types, so more generated Why this happensThe old trampoline was a one-liner. Merging it into the large function means every autodecodable That matches the review: wrapping two entry points around one implementation is cheaper than reimplementing the large function with a small Goal check
We did not achieve the goal that matters for Phobos. |
Rationale
Merge the two inner
byUTFoverloads into one function so autodecodable strings no longer re-enterbyUTFafterbyCodeUnit. NestedResulttypes now wraptypeof(units)instead of the original range type.The public eponymous
byUTF!(C, flag)API is unchanged, includingbyChar/byWchar/byDchar, two-stagebyUTF!C!Rinstantiation, qualifier aliasing, andauto ref/ by-valueR r. Behavior is unchanged; autodecodable inputs cost one fewer innerbyUTFinstantiation.Pre-review checklist
Existing
std.utfunittests cover this internal refactor; no new tests or changelog entry.LLM/AI disclosure
This PR was written entirely by an LLM/AI.