stdlib: remove bitwise operations on Bool

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
This commit is contained in:
Dmitri Hrybenko
2015-01-23 03:09:55 +00:00
parent b832ef90ab
commit bbf79427ac
10 changed files with 154 additions and 50 deletions

View File

@@ -185,7 +185,7 @@ public struct _UnitTestArrayBuffer<T> : _ArrayBufferType {
/// the return from this function, as this implementation generates
/// no shortcircuiting blocks.
_precondition(_base.hasStorage, "Cannot index empty buffer")
return (index >= 0) & (index < _base.value.count)
return (index >= 0) && (index < _base.value.count)
}
/// How many elements the buffer can store without reallocation