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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Mono.CecilX; using Mono.CecilX;
namespace Mirror.Weaver 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) public static List<MethodDefinition> GetMethods(this TypeDefinition td, string methodName)
{ {
List<MethodDefinition> methods = new List<MethodDefinition>(); // Linq allocations don't matter in weaver
foreach (MethodDefinition md in td.Methods) return td.Methods.Where(method => method.Name == methodName).ToList();
{
if (md.Name == methodName)
methods.Add(md);
}
return methods;
} }
public static MethodDefinition GetMethodInBaseType(this TypeDefinition td, string methodName) public static MethodDefinition GetMethodInBaseType(this TypeDefinition td, string methodName)