Skip to content

Commit 4f7d007

Browse files
committed
[string] Improve some small string comments
Clarify the expected behavior of some small string helper functions.
1 parent 0b93072 commit 4f7d007

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/public/core/SmallString.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ extension _SmallString {
8787
}
8888
}
8989

90+
// Get an integer equivalent to the _StringObject.discriminatedObjectRawBits
91+
// computed property.
9092
@inlinable @inline(__always)
9193
internal var rawDiscriminatedObject: UInt64 {
92-
// Discriminator is the most significant byte.
94+
// Reverse the bytes on big-endian systems.
9395
return _storage.1.littleEndian
9496
}
9597

@@ -317,7 +319,9 @@ extension _SmallString {
317319
#endif
318320

319321
extension UInt64 {
320-
// Fetches the `i`th byte, from left to right.
322+
// Fetches the `i`th byte in memory order. On little-endian systems the byte
323+
// at i=0 is the least significant byte (LSB) while on big-endian systems the
324+
// byte at i=7 is the LSB.
321325
@inlinable @inline(__always)
322326
internal func _uncheckedGetByte(at i: Int) -> UInt8 {
323327
_internalInvariant(i >= 0 && i < MemoryLayout<UInt64>.stride)
@@ -329,7 +333,9 @@ extension UInt64 {
329333
return UInt8(truncatingIfNeeded: (self &>> shift))
330334
}
331335

332-
// Sets the `i`th byte, from left to right.
336+
// Sets the `i`th byte in memory order. On little-endian systems the byte
337+
// at i=0 is the least significant byte (LSB) while on big-endian systems the
338+
// byte at i=7 is the LSB.
333339
@inlinable @inline(__always)
334340
internal mutating func _uncheckedSetByte(at i: Int, to value: UInt8) {
335341
_internalInvariant(i >= 0 && i < MemoryLayout<UInt64>.stride)

0 commit comments

Comments
 (0)