This commit is contained in:
bao-qian
2017-02-12 16:57:41 +00:00
parent 00ea4f8701
commit 86b2391543
4 changed files with 21 additions and 29 deletions

View File

@@ -35,20 +35,6 @@ namespace Wox.Plugin.ControlPanel
item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType); item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType);
} }
} }
Task.Run(() =>
{
var characters = controlPanelItems.Select(i => i.LocalizedString)
.Concat(controlPanelItems.Select(i => i.InfoTip));
Parallel.ForEach(characters, c =>
{
if (!string.IsNullOrWhiteSpace(c) && Alphabet.ContainsChinese(c))
{
Alphabet.PinyinComination(c);
}
});
});
} }
public List<Result> Query(Query query) public List<Result> Query(Query query)

View File

@@ -83,19 +83,6 @@ namespace Wox.Plugin.Program
}); });
Task.WaitAll(t1, t2); Task.WaitAll(t1, t2);
var characters = w.Select(p => p.Name)
.Concat(w.Select(p => p.Description))
.Concat(u.Select(p => p.DisplayName))
.Concat(u.Select(p => p.Description));
Parallel.ForEach(characters, c =>
{
if (!string.IsNullOrWhiteSpace(c) && Alphabet.ContainsChinese(c))
{
Alphabet.PinyinComination(c);
}
});
lock (IndexLock) lock (IndexLock)
{ {
_win32s = w; _win32s = w;

View File

@@ -4,17 +4,32 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using hyjiacan.util.p4n; using hyjiacan.util.p4n;
using hyjiacan.util.p4n.format; using hyjiacan.util.p4n.format;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage;
namespace Wox.Infrastructure namespace Wox.Infrastructure
{ {
public static class Alphabet public static class Alphabet
{ {
private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat(); private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat();
private static readonly ConcurrentDictionary<string, string[][]> PinyinCache = new ConcurrentDictionary<string, string[][]>(); private static ConcurrentDictionary<string, string[][]> PinyinCache;
private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage;
static Alphabet() public static void Initialize()
{ {
Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () =>
{
_pinyinStorage = new BinaryStorage<ConcurrentDictionary<string, string[][]>>("Pinyin");
PinyinCache = _pinyinStorage.TryLoad(new ConcurrentDictionary<string, string[][]>());
});
Log.Info($"|Wox.Infrastructure.Alphabet.Initialize|Number of preload pinyin combination<{PinyinCache.Count}>");
}
public static void Save()
{
_pinyinStorage.Save(PinyinCache);
} }
/// <summary> /// <summary>
@@ -98,5 +113,7 @@ namespace Wox.Infrastructure
).ToArray(); ).ToArray();
return combination; return combination;
} }
} }
} }

View File

@@ -53,6 +53,7 @@ namespace Wox
PluginManager.InitializePlugins(API); PluginManager.InitializePlugins(API);
ImageLoader.Initialize(); ImageLoader.Initialize();
Alphabet.Initialize();
Current.MainWindow = window; Current.MainWindow = window;
Current.MainWindow.Title = Infrastructure.Constant.Wox; Current.MainWindow.Title = Infrastructure.Constant.Wox;
@@ -136,6 +137,7 @@ namespace Wox
PluginManager.Save(); PluginManager.Save();
ImageLoader.Save(); ImageLoader.Save();
Alphabet.Save();
_disposed = true; _disposed = true;
} }