swift
a7780eaf - [Embedded] Drop dead foreign-String UTF-16 / breadcrumb machinery (#90493)

Commit
1 day ago
[Embedded] Drop dead foreign-String UTF-16 / breadcrumb machinery (#90493) Embedded Swift has no Objective-C runtime, so a String can never be foreign (UTF-16 / NSString-backed). Yet ~5.5 KB of foreign-String support survived -dead_strip in any Embedded binary using a non-trivial String: the foreign String.UTF8View accessors, and the native String.UTF16View indexing + _StringGuts.getUTF16Count + _StringBreadcrumbs cluster. Fence both roots at the _StringGuts layer under !_runtime(_ObjC): - isFastUTF8 folds to true and isForeign to false. The only foreign (providesFastUTF8: false) construction is Cocoa bridging, which is entirely _runtime(_ObjC) / @_unavailableInEmbedded. Folding makes the foreign fallback in every String.UTF8View accessor statically dead. - _slowEnsureMatchingEncoding returns markEncoding(i). It only exists to recover indices from verbatim-bridged NSStrings (impossible without the ObjC runtime) and is what pulled the native UTF-16 breadcrumb cluster in through ensureMatchingEncoding. _runtime(_ObjC) is already false for Linux/Windows/WASI too, so those non-Embedded targets shrink as well. The regular macOS/ObjC stdlib is unaffected.
Author
Parents
Loading