c# - Reusing code within a loop without using functions -
i have following code scans 2d array row row
for (int = 0; < rows; ++i) { (int j = 0; j < cols; ++j) { // code here scans 2d array using & j indices } }
this followed set of loops scan same array column column
for (int j = 0; j < cols; ++j) { (int = 0; < rows; ++i) { // code near duplicate of code in previous set of loops } }
the code inside above 2 sets of loops identical. there way can remove duplication? prefer not move code separate function code going run quite on pretty huge array, , afaik there isn't way force inlining in c#.
you may interested in aggressiveinlining option on methods
[methodimpl(methodimploptions.aggressiveinlining)] void method2() { // ... aggressive inlining. }
wiki
Comments
Post a Comment