mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Bitwise operations on Bool are redundant with other logic operations that stdlib already provides. The only reason to have them was to avoid branching in the short-circuiting && and ||. rdar://19340952 Surprisingly, replacing & and | in the standard library with && and || brought performance improvements and no significant performance regressions: RecursiveOwnedParameter 1.14 SelectionSort 1.19 Swift SVN r24674
13 lines
687 B
Swift
13 lines
687 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
func test_removedOperators(a: Bool, b: Bool) {
|
|
var t1 = ~a // expected-error {{'~' is unavailable: use the '!' operator instead}}
|
|
var t2 = a & b // expected-error {{'&' is unavailable: use the '&&' operator instead}}
|
|
var t3 = a | b // expected-error {{'|' is unavailable: use the '||' operator instead}}
|
|
var t4 = a ^ b // expected-error {{'^' is unavailable: use the '!=' operator instead}}
|
|
t4 &= a // expected-error {{'&=' is unavailable: use the '&&' operator instead}}
|
|
t4 |= a // expected-error {{'|=' is unavailable: use the '||' operator instead}}
|
|
t4 ^= a // expected-error {{'^=' is unavailable: use the '!=' operator instead}}
|
|
}
|
|
|