mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-05 21:17:14 -05: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
|
|
@ -78,7 +78,7 @@ public partial class Util
|
|||
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 @@ public static string[] GetStringList(string f)
|
|||
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 New Issue
Block a user