|
@@ -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))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|