浏览代码

Require Swift 4.2 or later

Norio Nomura 6 年之前
父节点
当前提交
cd839078df
共有 2 个文件被更改,包括 2 次插入10 次删除
  1. 1 1
      Package.swift
  2. 1 9
      Sources/Base32/Base32.swift

+ 1 - 1
Package.swift

@@ -1,4 +1,4 @@
-// swift-tools-version:4.0
+// swift-tools-version:4.2
 import PackageDescription
 
 var package = Package(

+ 1 - 9
Sources/Base32/Base32.swift

@@ -224,18 +224,10 @@ private func base32encode(_ data: UnsafeRawPointer, _ length: Int, _ table: [Int
     
     // return
     if let base32Encoded = String(validatingUTF8: resultBuffer) {
-#if swift(>=4.1)
         resultBuffer.deallocate()
-#else
-        resultBuffer.deallocate(capacity: resultBufferSize)
-#endif
         return base32Encoded
     } else {
-#if swift(>=4.1)
         resultBuffer.deallocate()
-#else
-        resultBuffer.deallocate(capacity: resultBufferSize)
-#endif
         fatalError("internal error")
     }
 }
@@ -305,7 +297,7 @@ private func base32decode(_ string: String, _ table: [UInt8]) -> [UInt8]? {
     
     // validate string
     let leastPaddingLength = getLeastPaddingLength(string)
-    if let index = string.unicodeScalars.index(where: {$0.value > 0xff || table[Int($0.value)] > 31}) {
+    if let index = string.unicodeScalars.firstIndex(where: {$0.value > 0xff || table[Int($0.value)] > 31}) {
         // index points padding "=" or invalid character that table does not contain.
         let pos = string.unicodeScalars.distance(from: string.unicodeScalars.startIndex, to: index)
         // if pos points padding "=", it's valid.