Skip to content

Investigate restoring a 10-byte small string representation for 32-bit platforms #82588

@glessard

Description

@glessard

Motivation

In #82442, in support of the String.utf8span property, we shortened the small string representation to a capacity of 8 bytes for 32-bit platforms without ABI stability. It may be possible to re-arrange structure _StringObject and enum _StringObject.Variant to provide a contiguous capacity of 10 bytes for those 32-bit platforms. We should carefully evaluate performance before and after in order to decide whether it should be done.

Proposed solution

My idea is to change _StringObject and Variant as follows:

internal enum Variant {
    case immortal(UInt)
    case native(AnyObject, UInt16)
}

where the UInt16 part of the associated value of .native stores the value currently stored in the _flags stored property of _StringObject.

Alternatives considered

This is not a necessity, but it could restore inline String instances to the same capacity as before.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    StringArea → standard library: The `String` typefeatureA feature request or implementation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions