mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
perf: eliminate boxing with lists (#901)
This commit is contained in:
parent
cc6e4f696d
commit
8f6d4cb22e
@ -338,22 +338,9 @@ public T this[int i]
|
||||
get => objects[i];
|
||||
set
|
||||
{
|
||||
bool changed = false;
|
||||
if (objects[i] == null)
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
else
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = !objects[i].Equals(value);
|
||||
}
|
||||
|
||||
objects[i] = value;
|
||||
if (changed)
|
||||
if (!EqualityComparer<T>.Default.Equals(objects[i], value))
|
||||
{
|
||||
objects[i] = value;
|
||||
AddOperation(Operation.OP_SET, i, value);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,18 @@ public void TestSet()
|
||||
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "yay", "!" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetNull()
|
||||
{
|
||||
serverSyncList[1] = null;
|
||||
SerializeDeltaTo(serverSyncList, clientSyncList);
|
||||
Assert.That(clientSyncList[1], Is.EqualTo(null));
|
||||
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", null, "!" }));
|
||||
serverSyncList[1] = "yay";
|
||||
SerializeDeltaTo(serverSyncList, clientSyncList);
|
||||
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "yay", "!" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveAt()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user