remove useless code

pull/541/head
ryanzhao 4 years ago
parent cd97b9c3e8
commit 7c2e25e25a

@ -30,8 +30,6 @@ public class FullTextSearchFinder: NSObject {
private static var tsAccountManager: TSAccountManager { private static var tsAccountManager: TSAccountManager {
return TSAccountManager.sharedInstance() return TSAccountManager.sharedInstance()
} }
public var newQueryTimestamp: UInt64 = 0
// MARK: - Querying // MARK: - Querying
@ -91,13 +89,6 @@ public class FullTextSearchFinder: NSObject {
guard let ext: YapDatabaseFullTextSearchTransaction = ext(transaction: transaction) else { guard let ext: YapDatabaseFullTextSearchTransaction = ext(transaction: transaction) else {
return return
} }
// HACK: Full text search is too expensive even though we drop the max search results
// to a reasonable number. And the async read can sometimes block a thread and make
// other read threads wait for it to finish. The timestamp is a workaround to ensure
// only one thread can be running the full text search at one time.
let currentQueryTimestamp = NSDate.millisecondTimestamp()
newQueryTimestamp = currentQueryTimestamp
let query = FullTextSearchFinder.query(searchText: searchText) let query = FullTextSearchFinder.query(searchText: searchText)
@ -108,7 +99,7 @@ public class FullTextSearchFinder: NSObject {
snippetOptions.endMatchText = "" snippetOptions.endMatchText = ""
snippetOptions.numberOfTokens = 5 snippetOptions.numberOfTokens = 5
ext.enumerateKeysAndObjects(matching: query, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) in ext.enumerateKeysAndObjects(matching: query, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) in
guard searchResultCount < maxSearchResults && currentQueryTimestamp >= self.newQueryTimestamp else { guard searchResultCount < maxSearchResults else {
stop.pointee = true stop.pointee = true
return return
} }

Loading…
Cancel
Save