Skip to content

Commit 8d4608f

Browse files
committed
[string] Improve some small string comments
Clarify the expected behavior of some small string helper functions.
1 parent 9587582 commit 8d4608f

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

@@ -312,7 +314,9 @@ extension _SmallString {
312314
#endif
313315

314316
extension UInt64 {
315-
// Fetches the `i`th byte, from left to right.
317+
// Fetches the `i`th byte in memory order. On little-endian systems the byte
318+
// at i=0 is the least significant byte (LSB) while on big-endian systems the
319+
// byte at i=7 is the LSB.
316320
@inlinable @inline(__always)
317321
internal func _uncheckedGetByte(at i: Int) -> UInt8 {
318322
_internalInvariant(i >= 0 && i < MemoryLayout<UInt64>.stride)
@@ -324,7 +328,9 @@ extension UInt64 {
324328
return UInt8(truncatingIfNeeded: (self &>> shift))
325329
}
326330

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

0 commit comments

Comments
 (0)