Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Keep old verison of code for Swift <5, to maintain compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-broadsheet committed May 8, 2020
1 parent 9376b0c commit 18755af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/PostgreSQL/Bind/BinaryUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import Core
extension UInt8 {
var lowercaseHexPair: String {
let hexString = String(self, radix: 16, uppercase: false)
#if swift(>=5.0)
return String(repeating: "0", count: 2 - hexString.count) + hexString
#else
return String(repeating: "0", count: 2 - hexString.characters.count) + hexString
#endif
}

var lowercaseBinaryString: String {
let bitString = String(self, radix: 2, uppercase: false)
#if swift(>=5.0)
return String(repeating: "0", count: 8 - bitString.count) + bitString
#else
return String(repeating: "0", count: 8 - bitString.characters.count) + bitString
#endif
}
}

Expand Down Expand Up @@ -190,7 +198,11 @@ struct BinaryUtils {

// The number of digits should be 4 (DEC_DIGITS),
// so pad if necessary.
#if swift(>=5.0)
return String(repeating: "0", count: Numeric.decDigits - stringDigits.count) + stringDigits
#else
return String(repeating: "0", count: Numeric.decDigits - stringDigits.characters.count) + stringDigits
#endif
}

/// Function for rounding numeric values.
Expand Down
4 changes: 4 additions & 0 deletions Sources/PostgreSQL/Bind/Bind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public final class Bind {

deinit {
if ownsMemory {
#if swift(>=5.0)
bytes.deallocate()
#else
bytes.deallocate(capacity: length)
#endif
}
}
}
Expand Down

0 comments on commit 18755af

Please sign in to comment.