mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-29 23:40:27 +00:00
clone cached string resources
don't share object references, need to be passed as new copies as the array contents can be modified need to clone on dict return to not pollute dict, and need to clone after dict add so that the first return doesn't equal the dict copy -- this one could be on the dict add... keep returns same.
This commit is contained in:
parent
d08bd25b4f
commit
9af0876352
1 changed files with 2 additions and 2 deletions
|
@ -78,7 +78,7 @@ namespace PKHeX.Core
|
|||
public static string[] GetStringList(string f)
|
||||
{
|
||||
if (stringListCache.ContainsKey(f))
|
||||
return stringListCache[f];
|
||||
return (string[])stringListCache[f].Clone();
|
||||
|
||||
var txt = GetStringResource(f); // Fetch File, \n to list.
|
||||
if (txt == null) return new string[0];
|
||||
|
@ -86,7 +86,7 @@ namespace PKHeX.Core
|
|||
for (int i = 0; i < rawlist.Length; i++)
|
||||
rawlist[i] = rawlist[i].Trim();
|
||||
stringListCache.Add(f, rawlist);
|
||||
return rawlist;
|
||||
return (string[])rawlist.Clone();
|
||||
}
|
||||
public static string[] GetStringList(string f, string l, string type = "text") => GetStringList($"{type}_{f}_{l}");
|
||||
public static string[] GetNulledStringArray(string[] SimpleStringList)
|
||||
|
|
Loading…
Reference in a new issue