mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
reuse ReadLength (#2292)
This commit is contained in:
parent
7c2a6595eb
commit
66be588512
@ -132,9 +132,7 @@ static MethodDefinition GenerateArrayReadFunc(TypeReference variable)
|
||||
ILProcessor worker = readerFunc.Body.GetILProcessor();
|
||||
|
||||
// int length = reader.ReadPackedInt32();
|
||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||
worker.Append(worker.Create(OpCodes.Call, GetReadFunc(WeaverTypes.Import<int>())));
|
||||
worker.Append(worker.Create(OpCodes.Stloc_0));
|
||||
GenerateReadLength(worker);
|
||||
|
||||
// if (length < 0) {
|
||||
// return null
|
||||
@ -172,6 +170,13 @@ static MethodDefinition GenerateArrayReadFunc(TypeReference variable)
|
||||
return readerFunc;
|
||||
}
|
||||
|
||||
private static void GenerateReadLength(ILProcessor worker)
|
||||
{
|
||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||
worker.Append(worker.Create(OpCodes.Call, GetReadFunc(WeaverTypes.Import<int>())));
|
||||
worker.Append(worker.Create(OpCodes.Stloc_0));
|
||||
}
|
||||
|
||||
static MethodDefinition GenerateEnumReadFunc(TypeReference variable)
|
||||
{
|
||||
MethodDefinition readerFunc = GenerateReaderFunction(variable);
|
||||
@ -212,9 +217,7 @@ static MethodDefinition GenerateArraySegmentReadFunc(TypeReference variable)
|
||||
ILProcessor worker = readerFunc.Body.GetILProcessor();
|
||||
|
||||
// int length = reader.ReadPackedInt32();
|
||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||
worker.Append(worker.Create(OpCodes.Call, GetReadFunc(WeaverTypes.Import<int>())));
|
||||
worker.Append(worker.Create(OpCodes.Stloc_0));
|
||||
GenerateReadLength(worker);
|
||||
|
||||
// T[] array = new int[length]
|
||||
worker.Append(worker.Create(OpCodes.Ldloc_0));
|
||||
@ -312,10 +315,8 @@ static MethodDefinition GenerateListReadFunc(TypeReference variable)
|
||||
|
||||
ILProcessor worker = readerFunc.Body.GetILProcessor();
|
||||
|
||||
// int count = reader.ReadPackedInt32();
|
||||
worker.Append(worker.Create(OpCodes.Ldarg_0));
|
||||
worker.Append(worker.Create(OpCodes.Call, GetReadFunc(WeaverTypes.Import<int>())));
|
||||
worker.Append(worker.Create(OpCodes.Stloc_0));
|
||||
// int length = reader.ReadPackedInt32();
|
||||
GenerateReadLength(worker);
|
||||
|
||||
// -1 is null list, so if count is less than 0 return null
|
||||
// if (count < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user