Range.contains(Range) currently checks all values instead of a bounds check, taking a very long time for large ranges. #70280
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
triage needed
This issue needs more specific labels
Description
The
ClosedRange.contains(ClosedRange)
check on seems to currently inherit fromCollection
which expands out all the values and checks each one. This means large ranges take a very long time to complete a .contains() check.Reproduction
Expected behavior
Range.contains(element) appears to already be optimized as a bounds check. I expected Range.contains(Range) would have been the same.
Environment
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
Additional information
Forum discussion, discovered as part of Advent of Code 2023
The text was updated successfully, but these errors were encountered: