mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-19 06:53:26 +08:00
[QuickAccent]Cache computed all language characters (#28657)
This commit is contained in:
parent
890b7f4286
commit
422813044d
@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using PowerToys.PowerAccentKeyboardService;
|
using PowerToys.PowerAccentKeyboardService;
|
||||||
|
|
||||||
namespace PowerAccent.Core
|
namespace PowerAccent.Core
|
||||||
@ -80,11 +81,15 @@ namespace PowerAccent.Core
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store the computed letters for each key, so that subsequent calls don't take as long.
|
||||||
|
private static ConcurrentDictionary<LetterKey, string[]> _allLanguagesCache = new ConcurrentDictionary<LetterKey, string[]>();
|
||||||
|
|
||||||
// All
|
// All
|
||||||
private static string[] GetDefaultLetterKeyALL(LetterKey letter)
|
private static string[] GetDefaultLetterKeyALL(LetterKey letter)
|
||||||
{
|
{
|
||||||
// would be even better to loop through Languages and call these functions dynamically, but I don't know how to do that!
|
if (!_allLanguagesCache.ContainsKey(letter))
|
||||||
return GetDefaultLetterKeyCA(letter)
|
{
|
||||||
|
_allLanguagesCache[letter] = GetDefaultLetterKeyCA(letter)
|
||||||
.Union(GetDefaultLetterKeyCUR(letter))
|
.Union(GetDefaultLetterKeyCUR(letter))
|
||||||
.Union(GetDefaultLetterKeyCY(letter))
|
.Union(GetDefaultLetterKeyCY(letter))
|
||||||
.Union(GetDefaultLetterKeyCZ(letter))
|
.Union(GetDefaultLetterKeyCZ(letter))
|
||||||
@ -113,7 +118,10 @@ namespace PowerAccent.Core
|
|||||||
.Union(GetDefaultLetterKeySR(letter))
|
.Union(GetDefaultLetterKeySR(letter))
|
||||||
.Union(GetDefaultLetterKeySV(letter))
|
.Union(GetDefaultLetterKeySV(letter))
|
||||||
.Union(GetDefaultLetterKeyTK(letter))
|
.Union(GetDefaultLetterKeyTK(letter))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _allLanguagesCache[letter];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currencies (source: https://www.eurochange.co.uk/travel-money/world-currency-abbreviations-symbols-and-codes-travel-money)
|
// Currencies (source: https://www.eurochange.co.uk/travel-money/world-currency-abbreviations-symbols-and-codes-travel-money)
|
||||||
|
Loading…
Reference in New Issue
Block a user