From 461a199d1566cdd25289f1db35f3a9c35cdbd3b3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 12 Jul 2021 13:34:14 -0600 Subject: [PATCH] Changes a couple of collection builders to not use the lazy (slightly more expensive ones) when not needed. --- .../Composing/LazyCollectionBuilderBase.cs | 17 ++++++++++++----- .../ManifestValueValidatorCollectionBuilder.cs | 4 ++-- .../MediaUrlGeneratorCollectionBuilder.cs | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/Composing/LazyCollectionBuilderBase.cs b/src/Umbraco.Core/Composing/LazyCollectionBuilderBase.cs index d41813f7d8..baae385af4 100644 --- a/src/Umbraco.Core/Composing/LazyCollectionBuilderBase.cs +++ b/src/Umbraco.Core/Composing/LazyCollectionBuilderBase.cs @@ -10,6 +10,9 @@ namespace Umbraco.Cms.Core.Composing /// The type of the builder. /// The type of the collection. /// The type of the items. + /// + /// This type of collection builder is typically used when type scanning is required (i.e. plugins). + /// public abstract class LazyCollectionBuilderBase : CollectionBuilderBase where TBuilder : LazyCollectionBuilderBase where TCollection : class, IBuilderCollection @@ -29,7 +32,7 @@ namespace Umbraco.Cms.Core.Composing { types.Clear(); _producers.Clear(); - _excluded.Clear(); + _excluded.Clear(); }); return This; } @@ -45,7 +48,8 @@ namespace Umbraco.Cms.Core.Composing Configure(types => { var type = typeof(T); - if (types.Contains(type) == false) types.Add(type); + if (types.Contains(type) == false) + types.Add(type); }); return This; } @@ -60,7 +64,8 @@ namespace Umbraco.Cms.Core.Composing Configure(types => { EnsureType(type, "register"); - if (types.Contains(type) == false) types.Add(type); + if (types.Contains(type) == false) + types.Add(type); }); return This; } @@ -90,7 +95,8 @@ namespace Umbraco.Cms.Core.Composing Configure(types => { var type = typeof(T); - if (_excluded.Contains(type) == false) _excluded.Add(type); + if (_excluded.Contains(type) == false) + _excluded.Add(type); }); return This; } @@ -105,7 +111,8 @@ namespace Umbraco.Cms.Core.Composing Configure(types => { EnsureType(type, "exclude"); - if (_excluded.Contains(type) == false) _excluded.Add(type); + if (_excluded.Contains(type) == false) + _excluded.Add(type); }); return This; } diff --git a/src/Umbraco.Core/PropertyEditors/ManifestValueValidatorCollectionBuilder.cs b/src/Umbraco.Core/PropertyEditors/ManifestValueValidatorCollectionBuilder.cs index 2247d3e62f..66a967c828 100644 --- a/src/Umbraco.Core/PropertyEditors/ManifestValueValidatorCollectionBuilder.cs +++ b/src/Umbraco.Core/PropertyEditors/ManifestValueValidatorCollectionBuilder.cs @@ -1,8 +1,8 @@ -using Umbraco.Cms.Core.Composing; +using Umbraco.Cms.Core.Composing; namespace Umbraco.Cms.Core.PropertyEditors { - public class ManifestValueValidatorCollectionBuilder : LazyCollectionBuilderBase + public class ManifestValueValidatorCollectionBuilder : SetCollectionBuilderBase { protected override ManifestValueValidatorCollectionBuilder This => this; } diff --git a/src/Umbraco.Core/PropertyEditors/MediaUrlGeneratorCollectionBuilder.cs b/src/Umbraco.Core/PropertyEditors/MediaUrlGeneratorCollectionBuilder.cs index 3ad03cb13c..57ab93832b 100644 --- a/src/Umbraco.Core/PropertyEditors/MediaUrlGeneratorCollectionBuilder.cs +++ b/src/Umbraco.Core/PropertyEditors/MediaUrlGeneratorCollectionBuilder.cs @@ -3,7 +3,7 @@ using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.PropertyEditors { - public class MediaUrlGeneratorCollectionBuilder : LazyCollectionBuilderBase + public class MediaUrlGeneratorCollectionBuilder : SetCollectionBuilderBase { protected override MediaUrlGeneratorCollectionBuilder This => this; }