mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Get the error strings as static variables to speed up StateErrorMessage (#25128)
This commit is contained in:
@@ -164,18 +164,20 @@ namespace winrt::PowerRenameUI::implementation
|
|||||||
|
|
||||||
std::wstring ExplorerItem::StateToErrorMessage()
|
std::wstring ExplorerItem::StateToErrorMessage()
|
||||||
{
|
{
|
||||||
auto factory = winrt::get_activation_factory<ResourceManager, IResourceManagerFactory>();
|
static auto factory = winrt::get_activation_factory<ResourceManager, IResourceManagerFactory>();
|
||||||
ResourceManager manager = factory.CreateInstance(L"resources.pri");
|
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)
|
switch (m_state)
|
||||||
{
|
{
|
||||||
case PowerRenameItemRenameStatus::ItemNameInvalidChar:
|
case PowerRenameItemRenameStatus::ItemNameInvalidChar:
|
||||||
{
|
{
|
||||||
return std::wstring{ manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_InvalidChar").ValueAsString() };
|
return std::wstring{ invalid_char_error };
|
||||||
}
|
}
|
||||||
case PowerRenameItemRenameStatus::ItemNameTooLong:
|
case PowerRenameItemRenameStatus::ItemNameTooLong:
|
||||||
{
|
{
|
||||||
return std::wstring{ manager.MainResourceMap().GetValue(L"Resources/ErrorMessage_FileNameTooLong").ValueAsString() };
|
return std::wstring{ name_too_long_error };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
Reference in New Issue
Block a user