Skip to content

Commit

Permalink
Minor perf improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrahhal committed May 1, 2017
1 parent 75b04b2 commit c88e606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions samples/Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public static IServiceProvider CreateProvider()
config.Configure<ModelA>(c =>
{
c.Remove(nameof(ModelA.Secret));
c.Custom((x, d) =>
{
d["Opt"] = Boxed.True;
});
});
config.Configure<ModelWithNested>(c =>
Expand Down
9 changes: 5 additions & 4 deletions src/MR.Augmenter/IAugmenter.Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ private void AugmentObject(object obj, TypeConfiguration typeConfiguration, AObj
}
}

foreach (var augment in typeConfiguration.Augments)
// perf: Avoid allocations.
for (int i = 0; i < typeConfiguration.Augments.Count; i++)
{
ApplyAugment(obj, root, augment, state);
ApplyAugment(obj, root, typeConfiguration.Augments[i], state);
}
foreach (var customThunk in typeConfiguration.CustomThunks)
for (int i = 0; i < typeConfiguration.CustomThunks.Count; i++)
{
ApplyCustomThunk(obj, root, customThunk);
ApplyCustomThunk(obj, root, typeConfiguration.CustomThunks[i]);
}
}

Expand Down

0 comments on commit c88e606

Please sign in to comment.