NetNewsWire/Frameworks/Data/DatabaseID.swift

27 lines
535 B
Swift
Raw Normal View History

//
// DatabaseID.swift
// Data
//
// Created by Brent Simmons on 7/15/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
// MD5 works because:
// * Its fast
// * Collisions arent going to happen with feed data
private var databaseIDCache = [String: String]()
public func databaseIDWithString(_ s: String) -> String {
if let identifier = databaseIDCache[s] {
return identifier
}
let identifier = (s as NSString).rs_md5Hash()
databaseIDCache[s] = identifier
return identifier
}