From 045b50a9292b5a1f114452df6be3fffa033a02a8 Mon Sep 17 00:00:00 2001 From: vis2k Date: Fri, 21 Aug 2020 11:31:25 +0200 Subject: [PATCH] Weaver Extensions: GetMethods uses Linq to simplify code --- Assets/Mirror/Editor/Weaver/Extensions.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Extensions.cs b/Assets/Mirror/Editor/Weaver/Extensions.cs index 44784a1ec..28727131b 100644 --- a/Assets/Mirror/Editor/Weaver/Extensions.cs +++ b/Assets/Mirror/Editor/Weaver/Extensions.cs @@ -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 GetMethods(this TypeDefinition td, string methodName) { - List methods = new List(); - 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)