Răsfoiți Sursa

xor array is default

Marcin Krzyżanowski 7 ani în urmă
părinte
comite
0b075a823b
1 a modificat fișierele cu 4 adăugiri și 4 ștergeri
  1. 4 4
      Sources/CryptoSwift/Utils.swift

+ 4 - 4
Sources/CryptoSwift/Utils.swift

@@ -60,11 +60,11 @@ func reversed(_ uint32: UInt32) -> UInt32 {
     return v
     return v
 }
 }
 
 
-func xor<T,V>(_ left: T, _ right: V) -> Array<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, T.IndexDistance == Int, V.Element == UInt8, V.IndexDistance == Int, V.Index == Int {
-    return Array(xor(left, right) as ArraySlice<UInt8>)
+func xor<T,V>(_ left: T, _ right: V) -> ArraySlice<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, T.IndexDistance == Int, V.Element == UInt8, V.IndexDistance == Int, V.Index == Int {
+    return xor(left, right).slice
 }
 }
 
 
-func xor<T,V>(_ left: T, _ right: V) -> ArraySlice<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, T.IndexDistance == Int, V.Element == UInt8, V.IndexDistance == Int, V.Index == Int {
+func xor<T,V>(_ left: T, _ right: V) -> Array<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, T.IndexDistance == Int, V.Element == UInt8, V.IndexDistance == Int, V.Index == Int {
     let length = Swift.min(left.count, right.count)
     let length = Swift.min(left.count, right.count)
 
 
     let buf = UnsafeMutablePointer<UInt8>.allocate(capacity: length)
     let buf = UnsafeMutablePointer<UInt8>.allocate(capacity: length)
@@ -79,7 +79,7 @@ func xor<T,V>(_ left: T, _ right: V) -> ArraySlice<UInt8> where T: RandomAccessC
         buf[i] = left[left.startIndex.advanced(by: i)] ^ right[right.startIndex.advanced(by: i)]
         buf[i] = left[left.startIndex.advanced(by: i)] ^ right[right.startIndex.advanced(by: i)]
     }
     }
 
 
-    return Array(UnsafeBufferPointer(start: buf, count: length)).slice
+    return Array(UnsafeBufferPointer(start: buf, count: length))
 }
 }