mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +03:00
Refactor slightly
This commit is contained in:
parent
38fb91f6c0
commit
c9facb60ea
@ -14,6 +14,23 @@ extension Array where Element: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
extension Array {
|
||||
|
||||
func data() -> Data {
|
||||
return self.withUnsafeBytes { pointer in
|
||||
if let baseAddr = pointer.baseAddress {
|
||||
return Data(bytes: baseAddr, count: pointer.count)
|
||||
}
|
||||
|
||||
let newPointer = UnsafeMutablePointer<Element>.allocate(capacity: self.count)
|
||||
for (index, element) in self.enumerated() {
|
||||
newPointer[index] = element
|
||||
}
|
||||
return Data(bytesNoCopy: newPointer, count: self.count, deallocator: .free)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension RandomAccessCollection where Index == Int {
|
||||
|
||||
func parallelMap<T>(
|
||||
|
@ -364,20 +364,3 @@ class UiBridge {
|
||||
}
|
||||
|
||||
private let timeout = CFTimeInterval(5)
|
||||
|
||||
private extension Array {
|
||||
|
||||
func data() -> Data {
|
||||
return self.withUnsafeBytes { pointer in
|
||||
if let baseAddr = pointer.baseAddress {
|
||||
return Data(bytes: baseAddr, count: pointer.count)
|
||||
}
|
||||
|
||||
let newPointer = UnsafeMutablePointer<Element>.allocate(capacity: self.count)
|
||||
for (index, element) in self.enumerated() {
|
||||
newPointer[index] = element
|
||||
}
|
||||
return Data(bytesNoCopy: newPointer, count: self.count, deallocator: .free)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user