Skip to content

Commit

Permalink
perf: Use WritePackedUInt32 in SyncList (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
atlv24 authored and paulpach committed Mar 30, 2019
1 parent 3ec7f6c commit 2db7576
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Assets/Mirror/Runtime/SyncList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void AddOperation(Operation op, int itemIndex, T item)
public void OnSerializeAll(NetworkWriter writer)
{
// if init, write the full list content
writer.Write(objects.Count);
writer.WritePackedUInt32((uint)objects.Count);

for (int i = 0; i < objects.Count; i++)
{
Expand All @@ -132,13 +132,13 @@ public void OnSerializeAll(NetworkWriter writer)
// thus the client will need to skip all the pending changes
// or they would be applied again.
// So we write how many changes are pending
writer.Write(changes.Count);
writer.WritePackedUInt32((uint)changes.Count);
}

public void OnSerializeDelta(NetworkWriter writer)
{
// write all the queued up changes
writer.Write(changes.Count);
writer.WritePackedUInt32((uint)changes.Count);

for (int i = 0; i < changes.Count; i++)
{
Expand Down Expand Up @@ -182,7 +182,7 @@ public void OnDeserializeAll(NetworkReader reader)
IsReadOnly = true;

// if init, write the full list content
int count = reader.ReadInt32();
int count = (int)reader.ReadPackedUInt32();

objects.Clear();
changes.Clear();
Expand All @@ -196,15 +196,15 @@ public void OnDeserializeAll(NetworkReader reader)
// We will need to skip all these changes
// the next time the list is synchronized
// because they have already been applied
changesAhead = reader.ReadInt32();
changesAhead = (int)reader.ReadPackedUInt32();
}

public void OnDeserializeDelta(NetworkReader reader)
{
// This list can now only be modified by synchronization
IsReadOnly = true;

int changesCount = reader.ReadInt32();
int changesCount = (int)reader.ReadPackedUInt32();

for (int i = 0; i < changesCount; i++)
{
Expand Down

0 comments on commit 2db7576

Please sign in to comment.