Use the articleID + accountID as a key for truncated summaries. This is *way* faster than using the entire body. It avoids a hash of a long string. (Note: we still need to toss the cache at the appropriate time.)

This commit is contained in:
Brent Simmons 2019-05-13 22:16:44 -07:00
parent 7c78d914be
commit 7b40ca221b

View File

@ -85,7 +85,8 @@ struct TimelineStringFormatter {
return "" return ""
} }
if let cachedBody = summaryCache[body] { let key = article.articleID + article.accountID
if let cachedBody = summaryCache[key] {
return cachedBody return cachedBody
} }
var s = body.rsparser_stringByDecodingHTMLEntities() var s = body.rsparser_stringByDecodingHTMLEntities()
@ -95,7 +96,7 @@ struct TimelineStringFormatter {
if s == "Comments" { // Hacker News. if s == "Comments" { // Hacker News.
s = "" s = ""
} }
summaryCache[body] = s summaryCache[key] = s
return s return s
} }