Skip to content

[SR-9438] Rewrite _uint64ToString etc to Swift #51902

@milseman

Description

@milseman
mannequin
Previous ID SR-9438
Radar rdar://problem/45768132
Original Reporter @milseman
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @xwu
Priority Medium

md5: 984ad19ce0bea9e1b771a70ebcb45775

relates to:

  • SR-7556 [String] Improve Int(_:String, radix:Int) size and performance

Issue Description:

The standard library has `String(_:radix:uppercase:)`, generic over `BinaryInteger`. However, almost-100% of the time, that BinaryInteger can be represented as an Int64. Also, 99% of the time that base is 10 or 16, and almost all of the rest is either 2 or 8. We should fast-path these most common usage.

Currently, we do have some checks inside `BinaryInteger._description(radix:uppercase:)`, which checks if bit-width is <= 64, calling `_[u]int64ToString`, but the cold path is not outlined.

`_[u]int64ToString` itself could be greatly improved for common radii, should be able to write its contents directly into a pre-allocated String buffer (or small string when appropriate), and shouldn't rely on the C function `_[u]int64ToStringImpl`

rdar://problem/45768132

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrella

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions