-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingSILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdeclarationsFeature: declarationsFeature: declarationsfor-in loopsFeature: for-in loopsFeature: for-in loopsfuncFeature → declarations: FunctionsFeature → declarations: FunctionsmutatingFeature → declarations → functions: Mutating functionsFeature → declarations → functions: Mutating functionsstatementsFeature: statementsFeature: statementsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
Description
This thread describes the issue: https://twitter.com/cpatrascudev/status/1661340099190161409. Swift chooses to insert an extra retain/release pair in the loop and this causes the in-place append fast path to not get hit because the uniqueness check fails.
Steps to reproduce
var result = ""
/*
for _ in 1...1000000 {
result += "abc"
}
*/
for _ in 1...1000000 {
result = result + "abc"
}
Expected behavior
This should append in-place.
Environment
- swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0 - Xcode 14.3
Build version 14E222b - macOS 13.0
Additional context
Built with -O.
Metadata
Metadata
Assignees
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingSILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdeclarationsFeature: declarationsFeature: declarationsfor-in loopsFeature: for-in loopsFeature: for-in loopsfuncFeature → declarations: FunctionsFeature → declarations: FunctionsmutatingFeature → declarations → functions: Mutating functionsFeature → declarations → functions: Mutating functionsstatementsFeature: statementsFeature: statementsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output