Skip to content

Commit

Permalink
re-save all the files in VSCode to strip trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed May 30, 2024
1 parent 2dedd9a commit 72734cd
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Sources/Base16/Base16.LowercaseDigits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension Base16
}
extension Base16.LowercaseDigits:BaseDigits
{
@inlinable public static
@inlinable public static
subscript(remainder:UInt8) -> UInt8
{
(remainder < 10 ? 0x30 : 0x61 - 10) &+ remainder
Expand Down
2 changes: 1 addition & 1 deletion Sources/Base16/Base16.UppercaseDigits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension Base16
}
extension Base16.UppercaseDigits:BaseDigits
{
@inlinable public static
@inlinable public static
subscript(remainder:UInt8) -> UInt8
{
(remainder < 10 ? 0x30 : 0x41 - 10) &+ remainder
Expand Down
2 changes: 1 addition & 1 deletion Sources/Base16/Base16.Values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension Base16.Values:Sequence, IteratorProtocol
{
while let digit:UInt8 = self.iterator.next()
{
switch digit
switch digit
{
case 0x30 ... 0x39: return digit - 0x30
case 0x61 ... 0x66: return digit + 10 - 0x61
Expand Down
2 changes: 1 addition & 1 deletion Sources/Base64/Base64.Digits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension Base64
}
extension Base64.Digits:BaseDigits
{
@inlinable public static
@inlinable public static
subscript(remainder:UInt8) -> UInt8
{
Self.ascii[Int.init(remainder & 0b0011_1111)]
Expand Down
26 changes: 13 additions & 13 deletions Sources/Base64/Base64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseDigits

/// A namespace for base-64 utilities.
public
enum Base64
enum Base64
{
/// Decodes some ``String``-like type containing an ASCII-encoded base-64 string
/// to some ``RangeReplaceableCollection`` type. Padding is not required.
Expand All @@ -15,7 +15,7 @@ enum Base64
/// This function uses the size of the input string to provide a capacity hint
/// for its output, and may over-allocate storage if the input contains many
/// non-digit characters.
@inlinable public static
@inlinable public static
func decode<ASCII, Bytes>(_ ascii:ASCII, to _:Bytes.Type = Bytes.self) -> Bytes
where Bytes:RangeReplaceableCollection, Bytes.Element == UInt8,
ASCII:StringProtocol
Expand All @@ -33,7 +33,7 @@ enum Base64
/// This function uses the size of the input string to provide a capacity hint
/// for its output, and may over-allocate storage if the input contains many
/// non-digit characters.
@inlinable public static
@inlinable public static
func decode<ASCII, Bytes>(_ ascii:ASCII, to _:Bytes.Type = Bytes.self) -> Bytes
where Bytes:RangeReplaceableCollection, Bytes.Element == UInt8,
ASCII:Sequence, ASCII.Element == UInt8
Expand Down Expand Up @@ -67,7 +67,7 @@ enum Base64
}

/// Encodes a sequence of bytes to a base-64 string with padding if needed.
@inlinable public static
@inlinable public static
func encode<Bytes>(_ bytes:Bytes) -> String where Bytes:Sequence, Bytes.Element == UInt8
{
var encoded:String = ""
Expand All @@ -77,28 +77,28 @@ enum Base64
{
encoded.append( Digits[first >> 2])

guard let second:UInt8 = bytes.next()
else
guard let second:UInt8 = bytes.next()
else
{
encoded.append(Digits[first << 4])
encoded.append("=")
encoded.append("=")
continue
continue
}

encoded.append( Digits[first << 4 | second >> 4])

guard let third:UInt8 = bytes.next()
else
guard let third:UInt8 = bytes.next()
else
{
encoded.append(Digits[second << 2])
encoded.append("=")
continue
continue
}

encoded.append( Digits[second << 2 | third >> 6])
encoded.append( Digits[third])
}
return encoded
return encoded
}
}
6 changes: 3 additions & 3 deletions Sources/Base64Tests/Base64Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct Base64Test

init(name:String,
degenerate:String? = nil,
canonical:String,
canonical:String,
expected:[UInt8])
{
self.name = name
Expand All @@ -22,7 +22,7 @@ extension Base64Test
{
init<UTF8>(name:String,
degenerate:String? = nil,
canonical:String,
canonical:String,
expected:UTF8) where UTF8:Collection, UTF8.Element == UInt8
{
self.init(name: name,
Expand All @@ -32,7 +32,7 @@ extension Base64Test
}
init(name:String,
degenerate:String? = nil,
canonical:String,
canonical:String,
expected:String)
{
self.init(name: name,
Expand Down
50 changes: 25 additions & 25 deletions Sources/CRC/CRC32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,65 @@ import Base16

#if swift(>=5.5)
extension CRC32:Sendable {}
#endif
#endif

@frozen public
struct CRC32:Hashable
{
public static
let table:[UInt32] = (0 ..< 256).map
public static
let table:[UInt32] = (0 ..< 256).map
{
(i:UInt32) in
(i:UInt32) in
(0 ..< 8).reduce(i){ (c, _) in (c & 1 * 0xed_b8_83_20) ^ c >> 1 }
}
public
var checksum:UInt32

public
var checksum:UInt32

@inlinable public
init(checksum:UInt32 = 0)
{
self.checksum = checksum
self.checksum = checksum
}
@inlinable public
@inlinable public
init<Message>(hashing message:Message)
where Message:Sequence, Message.Element == UInt8
where Message:Sequence, Message.Element == UInt8
{
self.init()
self.update(with: message)
}
@inlinable public
func updated<Message>(with message:Message) -> Self
where Message:Sequence, Message.Element == UInt8

@inlinable public
func updated<Message>(with message:Message) -> Self
where Message:Sequence, Message.Element == UInt8
{
var checksum:Self = self
var checksum:Self = self
checksum.update(with: message)
return checksum
}
@inlinable public mutating
func update<Message>(with message:Message)
where Message:Sequence, Message.Element == UInt8
@inlinable public mutating
func update<Message>(with message:Message)
where Message:Sequence, Message.Element == UInt8
{
self.checksum = ~message.reduce(~self.checksum)
self.checksum = ~message.reduce(~self.checksum)
{
(state:UInt32, byte:UInt8) in
(state:UInt32, byte:UInt8) in
Self.table[Int.init(UInt8.init(truncatingIfNeeded: state) ^ byte)] ^ state >> 8
}
}
}
extension CRC32:ExpressibleByIntegerLiteral
extension CRC32:ExpressibleByIntegerLiteral
{
@inlinable public
init(integerLiteral:UInt32)
{
self.init(checksum: integerLiteral)
}
}
extension CRC32:CustomStringConvertible
extension CRC32:CustomStringConvertible
{
@inlinable public
var description:String
@inlinable public
var description:String
{
Base16.encode(storing: self.checksum.bigEndian, with: Base16.LowercaseDigits.self)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/MessageAuthentication/MessageAuthenticationHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protocol MessageAuthenticationHash:RandomAccessCollection where Index == Int, El

/// Computes an instance of this hash for the given message.
init<Message>(hashing message:Message)
where Message:Collection, Message.Element == UInt8
where Message:Collection, Message.Element == UInt8
}
extension MessageAuthenticationHash
{
Expand Down Expand Up @@ -40,7 +40,7 @@ extension MessageAuthenticationHash
@inlinable public
init<Message, Key>(authenticating message:Message, key:Key)
where Message:Sequence, Message.Element == UInt8,
Key:Collection, Key.Element == UInt8
Key:Collection, Key.Element == UInt8
{
let key:MessageAuthenticationKey<Self> = .init(key)
self = key.authenticate(message)
Expand Down
10 changes: 5 additions & 5 deletions Sources/MessageAuthentication/MessageAuthenticationKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct MessageAuthenticationKey<Hash> where Hash:MessageAuthenticationHash

/// Creates a message authentication key from the given base key.
@inlinable public
init<Key>(_ key:Key) where Key:Collection, Key.Element == UInt8
init<Key>(_ key:Key) where Key:Collection, Key.Element == UInt8
{
let normalized:[UInt8]
let count:Int = key.count
Expand All @@ -27,11 +27,11 @@ struct MessageAuthenticationKey<Hash> where Hash:MessageAuthenticationHash
{
normalized = [UInt8].init(key) + repeatElement(0, count: Hash.stride - count)
}
else
else
{
normalized = [UInt8].init(key)
}

self.inner = normalized.map { $0 ^ 0x36 }
self.outer = normalized.map { $0 ^ 0x5c }
}
Expand Down Expand Up @@ -63,7 +63,7 @@ extension MessageAuthenticationKey

var hash:Hash = self.authenticate(salt)
var block:[UInt8] = .init(hash)

for _ in 1 ..< iterations
{
hash = self.authenticate(hash)
Expand All @@ -72,7 +72,7 @@ extension MessageAuthenticationKey
block[index] ^= byte
}
}

output.append(contentsOf: block)
}
return output
Expand Down
Loading

0 comments on commit 72734cd

Please sign in to comment.