From f964dcaf3b1830ca30b8cced9a9bc3311d3351cd Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Sun, 28 Jan 2024 16:14:36 -0800 Subject: [PATCH] Use concrete types when possible for improved performance --- .../OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs | 2 +- .../OrchardCore.Data.YesSql/DbConnectionValidator.cs | 6 +++--- .../Migration/DataMigrationManager.cs | 2 +- .../Descriptors/ShapeAlterationBuilder.cs | 2 +- .../Commands/DefaultCommandManager.cs | 2 +- .../OrchardCore/Shell/ShellDescriptorFeaturesManager.cs | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs index b2c887cd66f..1b7f17eec74 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Drivers/ContainedPartDisplayDriver.cs @@ -147,7 +147,7 @@ private async Task BuildViewModelAsync(string containerId, strin return Combine(results); } - private IDisplayResult GetListPartHeader(ContentItem containerContentItem, ListPartSettings listPartSettings) + private ShapeResult GetListPartHeader(ContentItem containerContentItem, ListPartSettings listPartSettings) => Initialize("ListPartHeaderAdmin", async model => { model.ContainerContentItem = containerContentItem; diff --git a/src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs b/src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs index 79c4e1492d7..d14c3cb8049 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql/DbConnectionValidator.cs @@ -164,7 +164,7 @@ connection is SqliteConnection sqliteConnection && return DbConnectionValidatorResult.DocumentTableFound; } - private static ISqlBuilder GetSelectBuilderForDocumentTable(ISqlBuilder sqlBuilder, string documentTable, string schema) + private static SqlBuilder GetSelectBuilderForDocumentTable(SqlBuilder sqlBuilder, string documentTable, string schema) { sqlBuilder.Select(); sqlBuilder.Selector("*"); @@ -174,7 +174,7 @@ private static ISqlBuilder GetSelectBuilderForDocumentTable(ISqlBuilder sqlBuild return sqlBuilder; } - private static ISqlBuilder GetSelectBuilderForShellDescriptorDocument(ISqlBuilder sqlBuilder, string documentTable, string schema) + private static SqlBuilder GetSelectBuilderForShellDescriptorDocument(SqlBuilder sqlBuilder, string documentTable, string schema) { sqlBuilder.Select(); sqlBuilder.Selector("*"); @@ -209,7 +209,7 @@ private static ISqlDialect GetSqlDialect(string databaseProvider) }; } - private static ISqlBuilder GetSqlBuilder(ISqlDialect sqlDialect, string tablePrefix, string tableNameSeparator) + private static SqlBuilder GetSqlBuilder(ISqlDialect sqlDialect, string tablePrefix, string tableNameSeparator) { var prefix = string.Empty; if (!string.IsNullOrWhiteSpace(tablePrefix)) diff --git a/src/OrchardCore/OrchardCore.Data.YesSql/Migration/DataMigrationManager.cs b/src/OrchardCore/OrchardCore.Data.YesSql/Migration/DataMigrationManager.cs index 7f5ccca3e05..3c4e64632b6 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql/Migration/DataMigrationManager.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql/Migration/DataMigrationManager.cs @@ -259,7 +259,7 @@ public async Task UpdateAsync(string featureId) /// /// Returns all the available IDataMigration instances for a specific module, and inject necessary builders /// - private IEnumerable GetDataMigrations(string featureId) + private List GetDataMigrations(string featureId) { var migrations = _dataMigrations .Where(dm => _typeFeatureProvider.GetFeatureForDependency(dm.GetType()).Id == featureId) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapeAlterationBuilder.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapeAlterationBuilder.cs index 98f4aa893ef..a8c5aab0f93 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapeAlterationBuilder.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapeAlterationBuilder.cs @@ -13,7 +13,7 @@ public class ShapeAlterationBuilder private IFeatureInfo _feature; private readonly string _shapeType; private readonly string _bindingName; - private readonly IList> _configurations = new List>(); + private readonly List> _configurations = []; public ShapeAlterationBuilder(IFeatureInfo feature, string shapeType) { diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Commands/DefaultCommandManager.cs b/src/OrchardCore/OrchardCore.Infrastructure/Commands/DefaultCommandManager.cs index 41e78679a68..45daec1900b 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Commands/DefaultCommandManager.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Commands/DefaultCommandManager.cs @@ -48,7 +48,7 @@ public IEnumerable GetCommandDescriptors() return _commandHandlers.SelectMany(x => _builder.Build(x.GetType()).Commands); } - private IEnumerable MatchCommands(CommandParameters parameters) + private List MatchCommands(CommandParameters parameters) { // Commands are matched with arguments. first argument // is the command others are arguments to the command. diff --git a/src/OrchardCore/OrchardCore/Shell/ShellDescriptorFeaturesManager.cs b/src/OrchardCore/OrchardCore/Shell/ShellDescriptorFeaturesManager.cs index 2e82b98b17e..5828b54fec9 100644 --- a/src/OrchardCore/OrchardCore/Shell/ShellDescriptorFeaturesManager.cs +++ b/src/OrchardCore/OrchardCore/Shell/ShellDescriptorFeaturesManager.cs @@ -190,7 +190,7 @@ private IEnumerable GetFeaturesToEnable(IFeatureInfo featureInfo, /// The list of feature ids which are currently enabled. /// Boolean parameter indicating if the feature should disable it's dependents. /// An enumeration of the features to enable, empty if 'force' = true and a dependent is enabled - private IEnumerable GetFeaturesToDisable(IFeatureInfo featureInfo, IEnumerable enabledFeatureIds, bool force) + private List GetFeaturesToDisable(IFeatureInfo featureInfo, IEnumerable enabledFeatureIds, bool force) { var featuresToDisable = _extensionManager .GetDependentFeatures(featureInfo.Id) @@ -204,7 +204,7 @@ private IEnumerable GetFeaturesToDisable(IFeatureInfo featureInfo, _logger.LogWarning(" To disable '{FeatureId}', additional features need to be disabled.", featureInfo.Id); } - return Enumerable.Empty(); + return []; } return featuresToDisable;