Closed rhcpfan closed 4 years ago
I've changed the code to map the header dates into a [String: Date?]
where keys are the original headers and the values are the parsed dates.
let dateStrings = headers.dropFirst(4)
let dateValues = dateStrings.map { dateFormatter.date(from: $0) }
let mappedDates = Dictionary(uniqueKeysWithValues: zip(dateStrings, dateValues))
...
for column in confirmedTimeSeries.values.indices {
let dateString = dateStrings[dateStrings.startIndex + column]
if let dateEntry = mappedDates[dateString], let date = dateEntry {
// use date
}
}
Merged. Thank you for your contribution!
Reduce memory usage and increase performance by parsing the timeseries headers from JHU and reuse them later.