List.contains - change in order to inline + typespecialize #15726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Credit to @jindraiva , implements and tests #15720 .
Benchmarks showing original issue with current
List.contains
impl: https://github.com/jindraivanek/Benchmarks-list-contains/blob/master/Benchmarks/BenchmarkDotNet.Artifacts/results/ListBenchmarks.ListTests-report-github.md(the here implemented option is called outerContainsWhatIf in the benchmarks - lowest allocation and fastest speed across the variants)
Basic example of how the lifting of equality check
(=)
from the inner rec function to the outer one makes inlining possible.https://sharplab.io/#v2:DYLgZgzgPsCmAuACAlgO2G2iD2BXesATgMLarwCGaEiAbhcLlhHoQMZYC8AsAFCIDEcJIkKw2KVKiKlyVVDSwAPCAEZEPfoO0BbCvDYALRCvUB3ZPEN9t2qIgDaAXUQBaAHyIwDCLBu2Be0N1EBBEeHUPRC5EYMQoezRpEjJKamjw1T5/ASSZVPkaekZmVg4cxD5hSQxpHHx8uWoAdUN9AEkwOgYmRBZcdi4K6rRarGQIAFl9I2i4HQ052AXObpLhhAExCTyUpoVWjq7lNQ0K3RnjU0QLK3PBe2c3T29gX3vA2JCwiOeUKcuX3iiSkjTSBza8E6GQi2S0uVBe3BEEOUK6xV6/UGFRxvGqYgguGASFWeAISMKiFQFFQjmpqAA3ABWAB0AAYGfSXFVNgSifBUdDSQ0KS1IdD6XSacz2ZyaS4gA