From 2c50adb6f2a81dfe2c8185d383e60ef93a5aa47c Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Mon, 17 Mar 2014 11:36:13 +0800 Subject: [PATCH] Revert use FuzzyMatcher on Bookmarks since it's too slow --- Wox.Plugin.System/BrowserBookmarks.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Wox.Plugin.System/BrowserBookmarks.cs b/Wox.Plugin.System/BrowserBookmarks.cs index 335cda55a..d57d0a5d2 100644 --- a/Wox.Plugin.System/BrowserBookmarks.cs +++ b/Wox.Plugin.System/BrowserBookmarks.cs @@ -22,8 +22,7 @@ namespace Wox.Plugin.System if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); var fuzzyMather = FuzzyMatcher.Create(query.RawQuery); - List returnList = bookmarks.Where(o => MatchProgram(o, fuzzyMather)).ToList(); - returnList = returnList.OrderByDescending(o => o.Score).ToList(); + List returnList = bookmarks.Where(o => MatchProgram(o, query.RawQuery.ToLower())).ToList(); return returnList.Select(c => new Result() { Title = c.Name, @@ -44,12 +43,11 @@ namespace Wox.Plugin.System } }).ToList(); } - private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher) + private bool MatchProgram(Bookmark bookmark, String query) { - if ((bookmark.Score = matcher.Score(bookmark.Name)) > 0) return true; - if ((bookmark.Score = matcher.Score(bookmark.PinyinName)) > 0) return true; - if ((bookmark.Score = matcher.Score(bookmark.Url) / 10) > 0) return true; - + if (bookmark.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) return true; + if (bookmark.Url.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) return true; + if (bookmark.PinyinName.Contains(query)) return true; return false; } @@ -127,7 +125,6 @@ namespace Wox.Plugin.System public string PinyinName { get; private set; } public string Url { get; set; } public string Source { get; set; } - public int Score { get; set; } /* TODO: since Source maybe unimportant, we just need to compare Name and Url */ public bool Equals(Bookmark other)