mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
Get the error strings as static variables to speed up StateErrorMessage (#25128)
This commit is contained in:
parent
9876695cdb
commit
07579c910a
@ -164,18 +164,20 @@ namespace winrt::PowerRenameUI::implementation
|
||||
|
||||
std::wstring ExplorerItem::StateToErrorMessage()
|
||||
{
|
||||
auto factory = winrt::get_activation_factory<ResourceManager, IResourceManagerFactory>();
|
||||
ResourceManager manager = factory.CreateInstance(L"resources.pri");
|
||||
static auto factory = winrt::get_activation_factory<ResourceManager, IResourceManagerFactory>();
|
||||
static ResourceManager manager = factory.CreateInstance(L"resources.pri");
|
||||
static auto invalid_char_error = manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_InvalidChar").ValueAsString();
|
||||
static auto name_too_long_error = manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_FileNameTooLong").ValueAsString();
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case PowerRenameItemRenameStatus::ItemNameInvalidChar:
|
||||
{
|
||||
return std::wstring{ manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_InvalidChar").ValueAsString() };
|
||||
return std::wstring{ invalid_char_error };
|
||||
}
|
||||
case PowerRenameItemRenameStatus::ItemNameTooLong:
|
||||
{
|
||||
return std::wstring{ manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_FileNameTooLong").ValueAsString() };
|
||||
return std::wstring{ name_too_long_error };
|
||||
}
|
||||
default:
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user