Weaver Extensions: GetMethods uses Linq to simplify code

This commit is contained in:
vis2k 2020-08-21 11:31:25 +02:00
parent 687c9002dd
commit 045b50a929

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.CecilX;
namespace Mirror.Weaver
@ -211,13 +212,8 @@ public static MethodDefinition GetMethod(this TypeDefinition td, string methodNa
public static List<MethodDefinition> GetMethods(this TypeDefinition td, string methodName)
{
List<MethodDefinition> methods = new List<MethodDefinition>();
foreach (MethodDefinition md in td.Methods)
{
if (md.Name == methodName)
methods.Add(md);
}
return methods;
// Linq allocations don't matter in weaver
return td.Methods.Where(method => method.Name == methodName).ToList();
}
public static MethodDefinition GetMethodInBaseType(this TypeDefinition td, string methodName)