From 8e00c5483387cc220f079e537f3440bbbddb8765 Mon Sep 17 00:00:00 2001
From: uye <99072975+ABA2396@users.noreply.github.com>
Date: Wed, 3 Apr 2024 10:36:17 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20LocalizationHelper?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MaaWpfGui/Helper/LocalizationHelper.cs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/MaaWpfGui/Helper/LocalizationHelper.cs b/src/MaaWpfGui/Helper/LocalizationHelper.cs
index e627dc2d2b..bce37cbfe1 100644
--- a/src/MaaWpfGui/Helper/LocalizationHelper.cs
+++ b/src/MaaWpfGui/Helper/LocalizationHelper.cs
@@ -11,10 +11,12 @@
// but WITHOUT ANY WARRANTY
//
+#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
@@ -77,7 +79,7 @@ namespace MaaWpfGui.Helper
{
var dictionary = new ResourceDictionary
{
- Source = new Uri($@"Res\Localizations\zh-cn.xaml", UriKind.Relative),
+ Source = new Uri(@"Res\Localizations\zh-cn.xaml", UriKind.Relative),
};
foreach (var key in dictionary.Keys)
{
@@ -127,7 +129,7 @@ namespace MaaWpfGui.Helper
/// The key of the string.
/// The language of the string
/// The string.
- public static string GetString(string key, string culture = null)
+ public static string GetString(string key, string? culture = null)
{
if (_culture == "pallas")
{
@@ -165,13 +167,13 @@ namespace MaaWpfGui.Helper
private static string GetPallasString()
{
int len = _pallasRand.Next(3, 6);
- string cheers = string.Empty;
+ StringBuilder cheersBuilder = new StringBuilder(len);
for (int i = 0; i < len; i++)
{
- cheers += _pallasChars[_pallasRand.Next(0, _pallasChars.Length)];
+ cheersBuilder.Append(_pallasChars[_pallasRand.Next(0, _pallasChars.Length)]);
}
- return cheers;
+ return cheersBuilder.ToString();
}
}
}