C# A delegate in is equivalent to a class ( Is not a value type , It's a reference type ),

When it is passed in as a formal parameter  
perhaps   System.Action b = TestB;//TestB It's a method ,
This is called once to generate 112bytes Of gcalloc
So we have to avoid update In this way .

In the same way , We try to avoid using it LINQ sentence , because Linq Statement requires us to pass in a delegate (delegate) Or method name , perhaps lambda expression . that GC And then it came into being .

It's very likely that we LINQ Will be used in sort functions , So it came into being GC It's not a small number .

The game's Caton will follow .

Test code :
List<int> list = new List<int>(); for(int i = 0; i < 100;i++) {
list.Add(UnityEngine.Random.Range(0, int.MaxValue)); } int target = 200; int
resultLinq = 0, resultFor = 0;
UnityEngine.Profiling.Profiler.BeginSample("MY_TEST LINQ"); resultLinq =
list.Find(i => i == target); UnityEngine.Profiling.Profiler.EndSample();
UnityEngine.Profiling.Profiler.BeginSample("MY_TEST FOR"); foreach (var i in
list) { if (i == target) { resultFor = i; } }

Profiler result : notice gcalloc It came into being


©2019-2020 Toolsou All rights reserved,
QQ Login interface implementation code implementation mysql Addition, deletion, modification and query of database JAVA Experiment 4 set and functional programming experiment about String How to create objects VHDL——4 choose 1 Data selector C language ( Guess numbers games ) Blue Bridge Cup MCU advanced module --NE555 I don't memorize eight part essays , You go to the interview ? Hill sorting of sorting algorithm ——c++ realization python What does built-in function mean _python What are the built-in functions