Skip to content

Commit 44a7da5

Browse files
committed
Optimize CompositePreCompiler
1 parent aec4564 commit 44a7da5

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

Orm/Xtensive.Orm/Orm/Providers/DomainHandler.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2003-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
55
// Created: 2008.05.19
66

@@ -20,6 +20,8 @@ namespace Xtensive.Orm.Providers
2020
/// </summary>
2121
public abstract class DomainHandler : DomainBoundHandler
2222
{
23+
private static readonly OrderingCorrector OrderingCorrector = new OrderingCorrector(ResolveOrderingDescriptor);
24+
2325
private Dictionary<Type, IMemberCompilerProvider> memberCompilerProviders;
2426

2527
/// <summary>
@@ -94,13 +96,12 @@ protected virtual IPreCompiler CreatePreCompiler(CompilerConfiguration configura
9496
var skipTakeCorrector = new SkipTakeCorrector(
9597
providerInfo.Supports(ProviderFeatures.NativeTake),
9698
providerInfo.Supports(ProviderFeatures.NativeSkip));
97-
return new CompositePreCompiler(
99+
return new CompositePreCompiler(configuration.Tags,
98100
applyCorrector,
99101
skipTakeCorrector,
100-
new RedundantColumnOptimizer(),
101-
new OrderingCorrector(ResolveOrderingDescriptor)) {
102-
Tags = configuration.Tags
103-
};
102+
RedundantColumnOptimizer.Instance,
103+
OrderingCorrector
104+
);
104105
}
105106

106107
/// <summary>
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2003-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexis Kochetov
55
// Created: 2009.03.30
66

@@ -12,29 +12,31 @@ namespace Xtensive.Orm.Rse.Compilation
1212
{
1313
public sealed class CompositePreCompiler : IPreCompiler
1414
{
15-
public List<IPreCompiler> Items { get; private set; }
16-
public IReadOnlyList<string> Tags { get; init; }
15+
public IReadOnlyList<IPreCompiler> items { get; }
16+
public IReadOnlyList<string> tags { get; }
1717

1818
public CompilableProvider Process(CompilableProvider rootProvider)
1919
{
2020
var provider = rootProvider;
21-
if (Tags != null) {
22-
foreach (var tag in Tags) {
21+
if (tags != null) {
22+
foreach (var tag in tags) {
2323
provider = new TagProvider(provider, tag);
2424
}
2525
}
2626

27-
foreach (var item in Items)
27+
foreach (var item in items) {
2828
provider = item.Process(provider);
29+
}
2930
return provider;
3031
}
3132

3233

3334
// Constructors
3435

35-
public CompositePreCompiler(params IPreCompiler[] preCompilers)
36+
public CompositePreCompiler(IReadOnlyList<string> tags, params IPreCompiler[] preCompilers)
3637
{
37-
Items = preCompilers.ToList();
38+
this.tags = tags;
39+
items = preCompilers;
3840
}
3941
}
4042
}

Orm/Xtensive.Orm/Orm/Rse/Transformation/RedundantColumnOptimizer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Xtensive.Orm.Rse.Transformation
1616
[Serializable]
1717
public class RedundantColumnOptimizer: IPreCompiler
1818
{
19+
public static RedundantColumnOptimizer Instance { get; } = new RedundantColumnOptimizer();
1920

2021
/// <inheritdoc/>
2122
CompilableProvider IPreCompiler.Process(CompilableProvider rootProvider)

0 commit comments

Comments
 (0)