From 8150f95910616d18b49ee7a17d0e090dfa7de3d1 Mon Sep 17 00:00:00 2001 From: Nikolay Pyanikov Date: Fri, 28 Jul 2023 13:47:15 +0300 Subject: [PATCH] Fixes breaking changes when using Span when building a map to resolve dependencies using "Resolve" methods. Micro performance improvements in "Resolve" methods. --- benchmarks/Pure.DI.Benchmarks/GetBenchmark.cs | 7 +- readme/Console.md | 2 +- readme/ConsoleTopLevelStatements.md | 2 +- readme/WebAPI.md | 2 +- readme/Wpf.md | 2 +- readme/a-few-partial-classes.md | 32 +++------- readme/advanced-interception.md | 32 +++------- readme/arguments.md | 32 +++------- readme/array.md | 32 +++------- readme/auto-bindings.md | 32 +++------- readme/child-composition.md | 32 +++------- readme/complex-generics.md | 32 +++------- readme/composition-roots.md | 32 +++------- readme/constructor-ordinal-attribute.md | 32 +++------- readme/custom-attributes.md | 32 +++------- readme/decorator.md | 32 +++------- readme/default-lifetime.md | 32 +++------- readme/dependent-compositions.md | 64 ++++++------------- readme/disposable-singleton.md | 32 +++------- readme/enumerable.md | 32 +++------- readme/factory.md | 32 +++------- readme/field-injection.md | 32 +++------- readme/func-with-arguments.md | 32 +++------- readme/func.md | 32 +++------- readme/generics.md | 32 +++------- readme/injection.md | 32 +++------- readme/interception.md | 32 +++------- readme/lazy.md | 32 +++------- readme/member-ordinal-attribute.md | 32 +++------- readme/method-injection.md | 32 +++------- readme/multi-contract-bindings.md | 32 +++------- readme/oncannotresolve-hint.md | 32 +++------- readme/ondependencyinjection-hint.md | 32 +++------- readme/onnewinstance-hint.md | 32 +++------- readme/overriding-the-bcl-binding.md | 32 +++------- readme/partial-class.md | 32 +++------- readme/perresolve.md | 32 +++------- readme/property-injection.md | 32 +++------- readme/required-properties-or-fields.md | 32 +++------- readme/resolve-methods.md | 32 +++------- readme/scope.md | 32 +++------- readme/service-collection.md | 32 +++------- readme/service-provider.md | 32 +++------- readme/singleton.md | 32 +++------- readme/span-and-readonlyspan.md | 32 +++------- readme/tag-attribute.md | 32 +++------- readme/tags.md | 32 +++------- readme/threadsafe-hint.md | 32 +++------- readme/tostring-hint.md | 32 +++------- readme/transient.md | 32 +++------- readme/tuple.md | 32 +++------- readme/type-attribute.md | 32 +++------- src/Pure.DI.Core/Components/Api.g.cs | 8 +-- .../Core/CSharp/ApiMembersBuilder.cs | 21 ++---- 54 files changed, 497 insertions(+), 1083 deletions(-) diff --git a/benchmarks/Pure.DI.Benchmarks/GetBenchmark.cs b/benchmarks/Pure.DI.Benchmarks/GetBenchmark.cs index 38aba15a..bf90cebc 100644 --- a/benchmarks/Pure.DI.Benchmarks/GetBenchmark.cs +++ b/benchmarks/Pure.DI.Benchmarks/GetBenchmark.cs @@ -177,15 +177,14 @@ private static string Get(Type key) private static string GetWhile(Type key) { int index = (int)(BucketSize * ((uint)RuntimeHelpers.GetHashCode(key) % Divisor)); - var finish = index + BucketSize; - do - { + int finish = index + BucketSize; + do { ref var pair = ref Pairs[index]; if (ReferenceEquals(pair.Key, key)) { return pair.Value; } - } while(++index < finish); + } while (++index < finish); throw new InvalidOperationException(); } diff --git a/readme/Console.md b/readme/Console.md index 0a96c592..ac27abaa 100644 --- a/readme/Console.md +++ b/readme/Console.md @@ -99,7 +99,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/ConsoleTopLevelStatements.md b/readme/ConsoleTopLevelStatements.md index 6543deab..4d516ea3 100644 --- a/readme/ConsoleTopLevelStatements.md +++ b/readme/ConsoleTopLevelStatements.md @@ -89,7 +89,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/WebAPI.md b/readme/WebAPI.md index 84eb90f4..85b58ec7 100644 --- a/readme/WebAPI.md +++ b/readme/WebAPI.md @@ -97,7 +97,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/Wpf.md b/readme/Wpf.md index 1d512260..83d5f7c3 100644 --- a/readme/Wpf.md +++ b/readme/Wpf.md @@ -68,7 +68,7 @@ The [project file](/samples/WpfAppNetCore/WpfAppNetCore.csproj) looks like this: - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/readme/a-few-partial-classes.md b/readme/a-few-partial-classes.md index 109cdc70..bfb65810 100644 --- a/readme/a-few-partial-classes.md +++ b/readme/a-few-partial-classes.md @@ -131,21 +131,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -156,21 +150,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/advanced-interception.md b/readme/advanced-interception.md index e00784c4..d4d25881 100644 --- a/readme/advanced-interception.md +++ b/readme/advanced-interception.md @@ -196,21 +196,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -221,21 +215,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/arguments.md b/readme/arguments.md index 451cf6f8..73b15a66 100644 --- a/readme/arguments.md +++ b/readme/arguments.md @@ -154,21 +154,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -179,21 +173,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/array.md b/readme/array.md index 25ed57b6..a9cb7a2e 100644 --- a/readme/array.md +++ b/readme/array.md @@ -133,21 +133,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -158,21 +152,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/auto-bindings.md b/readme/auto-bindings.md index 24e3a02b..4d4e7c6a 100644 --- a/readme/auto-bindings.md +++ b/readme/auto-bindings.md @@ -105,21 +105,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -130,21 +124,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/child-composition.md b/readme/child-composition.md index df1827a2..8e3b6104 100644 --- a/readme/child-composition.md +++ b/readme/child-composition.md @@ -155,21 +155,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -180,21 +174,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/complex-generics.md b/readme/complex-generics.md index d5a83907..a84f379d 100644 --- a/readme/complex-generics.md +++ b/readme/complex-generics.md @@ -161,21 +161,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -186,21 +180,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/composition-roots.md b/readme/composition-roots.md index 99d8b0fb..a15a3903 100644 --- a/readme/composition-roots.md +++ b/readme/composition-roots.md @@ -151,21 +151,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -176,21 +170,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/constructor-ordinal-attribute.md b/readme/constructor-ordinal-attribute.md index 74c7e089..56a3f73b 100644 --- a/readme/constructor-ordinal-attribute.md +++ b/readme/constructor-ordinal-attribute.md @@ -130,21 +130,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -155,21 +149,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/custom-attributes.md b/readme/custom-attributes.md index f16ba6f8..2c8f7592 100644 --- a/readme/custom-attributes.md +++ b/readme/custom-attributes.md @@ -155,21 +155,15 @@ partial class PersonComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -180,21 +174,15 @@ partial class PersonComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/decorator.md b/readme/decorator.md index 667dda3b..a26935bd 100644 --- a/readme/decorator.md +++ b/readme/decorator.md @@ -113,21 +113,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -138,21 +132,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/default-lifetime.md b/readme/default-lifetime.md index cf5c574b..fae8c855 100644 --- a/readme/default-lifetime.md +++ b/readme/default-lifetime.md @@ -157,21 +157,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -182,21 +176,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/dependent-compositions.md b/readme/dependent-compositions.md index bf99e1f8..cc1c4f2b 100644 --- a/readme/dependent-compositions.md +++ b/readme/dependent-compositions.md @@ -141,21 +141,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -166,21 +160,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } @@ -332,21 +320,15 @@ partial class OtherComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -357,21 +339,15 @@ partial class OtherComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/disposable-singleton.md b/readme/disposable-singleton.md index 76a73e5f..f826f9c2 100644 --- a/readme/disposable-singleton.md +++ b/readme/disposable-singleton.md @@ -149,21 +149,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -174,21 +168,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/enumerable.md b/readme/enumerable.md index 0ab16b35..976e8d0c 100644 --- a/readme/enumerable.md +++ b/readme/enumerable.md @@ -134,21 +134,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -159,21 +153,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/factory.md b/readme/factory.md index d8104211..6cafb014 100644 --- a/readme/factory.md +++ b/readme/factory.md @@ -144,21 +144,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -169,21 +163,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/field-injection.md b/readme/field-injection.md index 0831f7d2..fc27f083 100644 --- a/readme/field-injection.md +++ b/readme/field-injection.md @@ -117,21 +117,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -142,21 +136,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/func-with-arguments.md b/readme/func-with-arguments.md index b0a1cda8..96dbec7e 100644 --- a/readme/func-with-arguments.md +++ b/readme/func-with-arguments.md @@ -176,21 +176,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -201,21 +195,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/func.md b/readme/func.md index 85872fb9..4df3139a 100644 --- a/readme/func.md +++ b/readme/func.md @@ -127,21 +127,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -152,21 +146,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/generics.md b/readme/generics.md index aa27e6b3..704c70d0 100644 --- a/readme/generics.md +++ b/readme/generics.md @@ -134,21 +134,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -159,21 +153,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/injection.md b/readme/injection.md index 1f7dd154..f86caff3 100644 --- a/readme/injection.md +++ b/readme/injection.md @@ -129,21 +129,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -154,21 +148,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/interception.md b/readme/interception.md index edf51619..7a29c923 100644 --- a/readme/interception.md +++ b/readme/interception.md @@ -128,21 +128,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -153,21 +147,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/lazy.md b/readme/lazy.md index 5f3d4b19..1a711e11 100644 --- a/readme/lazy.md +++ b/readme/lazy.md @@ -137,21 +137,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -162,21 +156,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/member-ordinal-attribute.md b/readme/member-ordinal-attribute.md index 07099db0..430a78e8 100644 --- a/readme/member-ordinal-attribute.md +++ b/readme/member-ordinal-attribute.md @@ -158,21 +158,15 @@ partial class PersonComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -183,21 +177,15 @@ partial class PersonComposition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/method-injection.md b/readme/method-injection.md index e98bae3a..9270b2f4 100644 --- a/readme/method-injection.md +++ b/readme/method-injection.md @@ -118,21 +118,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -143,21 +137,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/multi-contract-bindings.md b/readme/multi-contract-bindings.md index 3913564f..05e06522 100644 --- a/readme/multi-contract-bindings.md +++ b/readme/multi-contract-bindings.md @@ -118,21 +118,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -143,21 +137,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/oncannotresolve-hint.md b/readme/oncannotresolve-hint.md index ad397a45..1b086c1e 100644 --- a/readme/oncannotresolve-hint.md +++ b/readme/oncannotresolve-hint.md @@ -150,21 +150,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -175,21 +169,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/ondependencyinjection-hint.md b/readme/ondependencyinjection-hint.md index 2234025d..c5a184ec 100644 --- a/readme/ondependencyinjection-hint.md +++ b/readme/ondependencyinjection-hint.md @@ -143,21 +143,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -168,21 +162,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/onnewinstance-hint.md b/readme/onnewinstance-hint.md index 0c116a79..7ea166dd 100644 --- a/readme/onnewinstance-hint.md +++ b/readme/onnewinstance-hint.md @@ -147,21 +147,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -172,21 +166,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/overriding-the-bcl-binding.md b/readme/overriding-the-bcl-binding.md index a91bb362..18c3dd24 100644 --- a/readme/overriding-the-bcl-binding.md +++ b/readme/overriding-the-bcl-binding.md @@ -125,21 +125,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -150,21 +144,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/partial-class.md b/readme/partial-class.md index 6856f119..f1e06e12 100644 --- a/readme/partial-class.md +++ b/readme/partial-class.md @@ -115,21 +115,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -140,21 +134,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/perresolve.md b/readme/perresolve.md index ddf05b2b..ef095d62 100644 --- a/readme/perresolve.md +++ b/readme/perresolve.md @@ -125,21 +125,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -150,21 +144,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/property-injection.md b/readme/property-injection.md index 38790dd6..af2a19f8 100644 --- a/readme/property-injection.md +++ b/readme/property-injection.md @@ -115,21 +115,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -140,21 +134,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/required-properties-or-fields.md b/readme/required-properties-or-fields.md index 671f1596..566ca29e 100644 --- a/readme/required-properties-or-fields.md +++ b/readme/required-properties-or-fields.md @@ -137,21 +137,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -162,21 +156,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/resolve-methods.md b/readme/resolve-methods.md index 840308ea..80e64f69 100644 --- a/readme/resolve-methods.md +++ b/readme/resolve-methods.md @@ -153,21 +153,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -178,21 +172,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/scope.md b/readme/scope.md index 5dce37a5..ab424025 100644 --- a/readme/scope.md +++ b/readme/scope.md @@ -205,21 +205,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -230,21 +224,15 @@ partial class Composition: System.IDisposable [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/service-collection.md b/readme/service-collection.md index 7de12bc6..a1f4370a 100644 --- a/readme/service-collection.md +++ b/readme/service-collection.md @@ -192,21 +192,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -217,21 +211,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/service-provider.md b/readme/service-provider.md index 54972e6d..4ba0860e 100644 --- a/readme/service-provider.md +++ b/readme/service-provider.md @@ -167,21 +167,15 @@ partial class ServiceProvider [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object GetService(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -192,21 +186,15 @@ partial class ServiceProvider [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/singleton.md b/readme/singleton.md index 4ce87f4d..3d36b93d 100644 --- a/readme/singleton.md +++ b/readme/singleton.md @@ -143,21 +143,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -168,21 +162,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/span-and-readonlyspan.md b/readme/span-and-readonlyspan.md index 3e3665d5..2c172e83 100644 --- a/readme/span-and-readonlyspan.md +++ b/readme/span-and-readonlyspan.md @@ -125,21 +125,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -150,21 +144,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/tag-attribute.md b/readme/tag-attribute.md index 6d3f583c..c7c96b91 100644 --- a/readme/tag-attribute.md +++ b/readme/tag-attribute.md @@ -136,21 +136,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -161,21 +155,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/tags.md b/readme/tags.md index c41c3d31..9e9dfe59 100644 --- a/readme/tags.md +++ b/readme/tags.md @@ -190,21 +190,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -215,21 +209,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 4)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/threadsafe-hint.md b/readme/threadsafe-hint.md index e5de5bb3..0c6047e4 100644 --- a/readme/threadsafe-hint.md +++ b/readme/threadsafe-hint.md @@ -112,21 +112,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -137,21 +131,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/tostring-hint.md b/readme/tostring-hint.md index 5b4bb755..bc2f30c8 100644 --- a/readme/tostring-hint.md +++ b/readme/tostring-hint.md @@ -110,21 +110,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -135,21 +129,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/transient.md b/readme/transient.md index 2704ce7f..896912d2 100644 --- a/readme/transient.md +++ b/readme/transient.md @@ -128,21 +128,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -153,21 +147,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/tuple.md b/readme/tuple.md index 0a175355..5cce5f95 100644 --- a/readme/tuple.md +++ b/readme/tuple.md @@ -126,21 +126,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -151,21 +145,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/readme/type-attribute.md b/readme/type-attribute.md index 52e3fc15..c7425014 100644 --- a/readme/type-attribute.md +++ b/readme/type-attribute.md @@ -127,21 +127,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.Resolve(this); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.Resolve(this); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root of type {type}."); } @@ -152,21 +146,15 @@ partial class Composition [global::System.Runtime.CompilerServices.MethodImpl((global::System.Runtime.CompilerServices.MethodImplOptions)0x300)] public object Resolve(global::System.Type type, object? tag) { - int index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); - ref var pair = ref _bucketsM07D28di[index]; - if (ReferenceEquals(pair.Key, type)) - { - return pair.Value.ResolveByTag(this, tag); - } - - for (int i = index + 1; i < index + _bucketSizeM07D28di; i++) - { - pair = ref _bucketsM07D28di[i]; + var index = (int)(_bucketSizeM07D28di * ((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % 1)); + var finish = index + _bucketSizeM07D28di; + do { + ref var pair = ref _bucketsM07D28di[index]; if (ReferenceEquals(pair.Key, type)) { return pair.Value.ResolveByTag(this, tag); } - } + } while (++index < finish); throw new global::System.InvalidOperationException($"Cannot resolve composition root \"{tag}\" of type {type}."); } diff --git a/src/Pure.DI.Core/Components/Api.g.cs b/src/Pure.DI.Core/Components/Api.g.cs index 507d271b..7ed3765f 100644 --- a/src/Pure.DI.Core/Components/Api.g.cs +++ b/src/Pure.DI.Core/Components/Api.g.cs @@ -566,7 +566,7 @@ public static Pair[] Create( Pair[] pairs) { bucketSize = 0; - Span bucketSizes = divisor < 1024 ? stackalloc int[(int)divisor] : new int[divisor]; + int[] bucketSizes = new int[divisor]; for (int i = 0; i < pairs.Length; i++) { int bucket = (int)(((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(pairs[i].Key)) % divisor); @@ -582,9 +582,9 @@ public static Pair[] Create( for (int i = 0; i < pairs.Length; i++) { int bucket = (int)(((uint)global::System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(pairs[i].Key)) % divisor); - var index = bucketSizes[bucket] - 1; - buckets[bucket * bucketSize + index] = pairs[i]; - bucketSizes[bucket] = index; + var index = bucketSizes[bucket]; + buckets[bucket * bucketSize + bucketSize - index] = pairs[i]; + bucketSizes[bucket] = index - 1; } return buckets; diff --git a/src/Pure.DI.Core/Core/CSharp/ApiMembersBuilder.cs b/src/Pure.DI.Core/Core/CSharp/ApiMembersBuilder.cs index c1511b06..7ace26bf 100644 --- a/src/Pure.DI.Core/Core/CSharp/ApiMembersBuilder.cs +++ b/src/Pure.DI.Core/Core/CSharp/ApiMembersBuilder.cs @@ -130,22 +130,12 @@ private static void CreateObjectResolverMethod( var divisor = Buckets.GetDivisor((uint)resolvers.Count); if (resolvers.Any()) { - code.AppendLine($"int index = (int)({ResolversFieldsBuilder.BucketSizeFieldName} * ((uint){Constant.SystemNamespace}Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % {divisor}));"); - code.AppendLine($"ref var pair = ref {ResolversFieldsBuilder.BucketsFieldName}[index];"); - code.AppendLine("if (ReferenceEquals(pair.Key, type))"); - code.AppendLine("{"); + code.AppendLine($"var index = (int)({ResolversFieldsBuilder.BucketSizeFieldName} * ((uint){Constant.SystemNamespace}Runtime.CompilerServices.RuntimeHelpers.GetHashCode(type) % {divisor}));"); + code.AppendLine($"var finish = index + {ResolversFieldsBuilder.BucketSizeFieldName};"); + code.AppendLine("do {"); using (code.Indent()) { - code.AppendLine($"return pair.Value.{resolveMethodName}({resolveMethodArgs});"); - } - - code.AppendLine("}"); - code.AppendLine(); - code.AppendLine($"for (int i = index + 1; i < index + {ResolversFieldsBuilder.BucketSizeFieldName}; i++)"); - code.AppendLine("{"); - using (code.Indent()) - { - code.AppendLine($"pair = ref {ResolversFieldsBuilder.BucketsFieldName}[i];"); + code.AppendLine($"ref var pair = ref {ResolversFieldsBuilder.BucketsFieldName}[index];"); code.AppendLine("if (ReferenceEquals(pair.Key, type))"); code.AppendLine("{"); using (code.Indent()) @@ -155,7 +145,8 @@ private static void CreateObjectResolverMethod( code.AppendLine("}"); } - code.AppendLine("}"); + + code.AppendLine("} while (++index < finish);"); code.AppendLine(); }