Update for SE-0107: UnsafeRawPointer
This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.
These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.
Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
This is another necessary step in introducing changes
for SE-0107: UnsafeRawPointer.
UnsafeRawPointer is great for bytewise pointer operations.
OpaquePointer goes away.
The _RawByte type goes away.
StringBuffer always binds memory to the correct CodeUnit
when allocating memory.
Before accessing the string, a dynamic element width check
allows us to assume the bound memory type.
Generic entry points like atomicCompareExchange no longer handle
both kinds of pointers. Normally that's good because you
should not be using generics in that case, just upcast
to raw pointer. However, with pointers-to-pointers
you can't do that.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md
- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
(like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.
I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)
The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
This is more or less a workaround for some optimizations (mainly ARC opt) to avoid performance degradation with the upcoming inliner changes
In some situations it makes a big difference for ARC opt if a function is inlined or not, althought this shouldn't be the case.
This commit is the result of auditing the following files:
* StringBuffer.swift
* StringCharacterView.swift
* StringCore.swift
* StringInterpolation.swift.gyb
* StringLegacy.swift
At DaveA's suggestion, I took a mostly mechanical approach to this:
pointers and numeric types start using += 1, and indexes use
i = i.successor(). The index model is likely to be revised in
Swift 3 anyway, so micro-optimizing this code syntactically isn't
super important.
There is some performance concern of this patch, since some
in-place succesor operations are more efficient than
i = i.successor(). The one that seems particularly at issue is the
instance in the implementation of partition(), which I changed to
use i._successorInPlace(). If other instances lead to a perf issue,
they can be changed to use that as well.