Skip to content

Commit

Permalink
using raw bytes as ints for date
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdsupremacist committed Apr 6, 2020
1 parent 03d967f commit d41c53b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ func resolveArguments(for value: Any, using type: Any.Type, isNil: Bool = false)
if isNil {
return [.int(.int(0))]
}
let pointer = UnsafeMutableRawPointer.allocate(byteCount: MemoryLayout<Date>.size, alignment: MemoryLayout<Date>.size)
pointer.storeBytes(of: value as! Date, as: Date.self)
return [.int(.pointer(pointer))]
let bytes = withUnsafeBytes(of: value as! Date) { $0.bindMemory(to: Int.self) }
return Array(bytes).map { .int(.int($0)) }
}

let (mangledName, kind, genericTypes, properties) = try typeInfo(of: type, .mangledName, .kind, .genericTypes, .properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ func resolveArguments(for value: Any, using type: Any.Type, isNil: Bool = false)
if isNil {
return [.int(.int(0))]
}
let pointer = UnsafeMutableRawPointer.allocate(byteCount: MemoryLayout<Date>.size, alignment: MemoryLayout<Date>.size)
pointer.storeBytes(of: value as! Date, as: Date.self)
return [.int(.pointer(pointer))]
let bytes = withUnsafeBytes(of: value as! Date) { $0.bindMemory(to: Int.self) }
return Array(bytes).map { .int(.int($0)) }
}

let (mangledName, kind, genericTypes, properties) = try typeInfo(of: type, .mangledName, .kind, .genericTypes, .properties)
Expand Down

0 comments on commit d41c53b

Please sign in to comment.