Skip to content

Commit bcc9356

Browse files
committed
[SE-0368] StaticBigInt: use better buffer slices
1 parent edf4b7d commit bcc9356

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

stdlib/public/core/StaticBigInt.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extension StaticBigInt: CustomDebugStringConvertible {
148148
var result = String(unsafeUninitializedCapacity: capacity) { utf8 in
149149

150150
// Pre-initialize with zeros, ignoring extra capacity.
151-
var utf8 = UnsafeMutableBufferPointer(rebasing: utf8.prefix(capacity))
151+
var utf8 = utf8.prefix(capacity)
152152
utf8.initialize(repeating: UInt8(ascii: "0"))
153153

154154
// Use a 32-bit element type, to generate small hexadecimal strings.
@@ -171,12 +171,8 @@ extension StaticBigInt: CustomDebugStringConvertible {
171171

172172
// Overwrite trailing zeros with hexadecimal digits.
173173
let hexDigits = String(element, radix: 16, uppercase: true).utf8
174-
_ = UnsafeMutableBufferPointer(
175-
rebasing: utf8.suffix(hexDigits.count)
176-
).initialize(from: hexDigits)
177-
utf8 = UnsafeMutableBufferPointer(
178-
rebasing: utf8.dropLast(hexDigitsPerElement)
179-
)
174+
_ = utf8.suffix(hexDigits.count).update(fromContentsOf: hexDigits)
175+
utf8 = utf8.dropLast(hexDigitsPerElement)
180176
}
181177
return capacity
182178
}

0 commit comments

Comments
 (0)