mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 16:27:19 +00:00
use struct so that it doesn't allocate memory
This commit is contained in:
parent
5436f71840
commit
2c4d09b8c2
1 changed files with 3 additions and 3 deletions
|
@ -16,7 +16,7 @@ namespace SanAndreasUnity.Net
|
||||||
private readonly StringSyncDictionary m_syncDictionary;
|
private readonly StringSyncDictionary m_syncDictionary;
|
||||||
private readonly Dictionary<string, List<System.Action<string>>> m_callbacks = new Dictionary<string, List<Action<string>>>();
|
private readonly Dictionary<string, List<System.Action<string>>> m_callbacks = new Dictionary<string, List<Action<string>>>();
|
||||||
|
|
||||||
private class ArrayWrapper<T>
|
private struct ArrayWrapper<T> // use struct so that it doesn't allocate memory
|
||||||
{
|
{
|
||||||
public T[] array;
|
public T[] array;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace SanAndreasUnity.Net
|
||||||
string str = GetString(key);
|
string str = GetString(key);
|
||||||
if (str == null)
|
if (str == null)
|
||||||
return null;
|
return null;
|
||||||
return JsonUtility.FromJson<ArrayWrapper<string>>(str)?.array;
|
return JsonUtility.FromJson<ArrayWrapper<string>>(str).array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStringArray(string key, string[] array)
|
public void SetStringArray(string key, string[] array)
|
||||||
|
@ -170,7 +170,7 @@ namespace SanAndreasUnity.Net
|
||||||
string str = GetString(key);
|
string str = GetString(key);
|
||||||
if (str == null)
|
if (str == null)
|
||||||
return null;
|
return null;
|
||||||
return JsonUtility.FromJson<ArrayWrapper<float>>(str)?.array;
|
return JsonUtility.FromJson<ArrayWrapper<float>>(str).array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFloatArray(string key, float[] array)
|
public void SetFloatArray(string key, float[] array)
|
||||||
|
|
Loading…
Reference in a new issue