NetNewsWire/Frameworks/Data/DatabaseID.swift
2017-09-02 16:08:02 -07:00

28 lines
549 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// DatabaseID.swift
// Data
//
// Created by Brent Simmons on 7/15/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
import RSCore
// 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
}