Commit Graph

69 Commits

Author SHA1 Message Date
Dave Abrahams
d1aa6fe2b8 [stdlib] Rename Array internals for clarity
Because _demandUniqueMutableBuffer returns nil if the buffer already
exists, rename to _createUniqueMutableBuffer.

Because _requestUniqueMutableBuffer may return native backing storage
for a slice whose bounds don't exactly match the backing storage, rename
to _requestUniqueMutableBackingBuffer

Swift SVN r19214
2014-06-26 01:49:54 +00:00
Dave Abrahams
f146b40401 [stdlib] 80-column fix
Swift SVN r19213
2014-06-26 01:49:53 +00:00
Doug Gregor
37df5c430c Update standard library to use [T] array syntax.
Swift SVN r19190
2014-06-25 23:39:20 +00:00
Manman Ren
544cd15eb9 [stdlib] add noinline on makeUnique.
Swift SVN r19174
2014-06-25 18:39:49 +00:00
Nadav Rotem
a3d2883887 Refactor the makeUnique parts of array subscript outside of the closure. We inline this closure with the new pass order.
Swift SVN r19164
2014-06-25 17:13:50 +00:00
Joe Groff
87dd6ed419 stdlib: Add #ifs to help stage in pointer conversions.
Hide the bridged C*Pointer types if the stdlib is built with -DENABLE_POINTER_CONVERSIONS as a temporary transition aid.

Swift SVN r19159
2014-06-25 16:37:25 +00:00
Jordan Rose
cca27d02a0 Tag everything in the standard library with accessibility attributes.
Keep calm: remember that the standard library has many more public exports
than the average target, and that this contains ALL of them at once.
I also deliberately tried to tag nearly every top-level decl, even if that
was just to explicitly mark things @internal, to make sure I didn't miss
something.

This does export more than we might want to, mostly for protocol conformance
reasons, along with our simple-but-limiting typealias rule. I tried to also
mark things private where possible, but it's really going to be up to the
standard library owners to get this right. This is also only validated
against top-level access control; I haven't fully tested against member-level
access control yet, and none of our semantic restrictions are in place.

Along the way I also noticed bits of stdlib cruft; to keep this patch
understandable, I didn't change any of them.

Swift SVN r19145
2014-06-24 21:32:18 +00:00
Doug Gregor
fd62de4373 Use bridgeFromObjectiveCConditional where we want conditional bridging.
More of <rdar://problem/17319154>.


Swift SVN r19038
2014-06-20 07:41:50 +00:00
Michael Gottesman
8de060ff3f Revert "[stdlib] mask unused bits in uniqueness checks"
Revert "[stdlib] Use an enum for ArrayBuffer storage"

This reverts commit r18996.
This reverts commit r18954.

The optimizer is not ready yet to handle this change especially given
the time until Beta 3. After speaking with DaveA, we agreed to revert
this and take such large changes onto private branches until we are sure
that the optimizer is ready to handle them rather than risking
performance regressions due to hitting the "optimization cliff".

Swift SVN r19026
2014-06-20 01:41:04 +00:00
Dmitri Hrybenko
c4fd1c4092 stdlib: explain the trick used to achieve @noinline without @noinline
Swift SVN r19018
2014-06-19 23:53:09 +00:00
Chris Lattner
62cad3dce8 add a "..<" operator, which is an alias for ".." and switch the stdlib to use it.
Until I have a chance to update the testsuite, we'll accept both.



Swift SVN r18998
2014-06-19 05:42:29 +00:00
Dave Abrahams
89fb9c8bea [stdlib] Factor out Array growth calculation
This enables testing of other growth factors, per
<rdar://problem/17230502>.  See the radar for basic performance test
results confirming (to the degree practical) that 2x growth is better
than 1.5x in our current system.

Swift SVN r18990
2014-06-18 23:17:06 +00:00
Dave Abrahams
a4c232bab8 [stdlib] Use an enum for ArrayBuffer storage
instead of reinterpretCasting all over the place.  This should make it
easier on the ARC optimizer.

Addresses <rdar://problem/17312221>

Swift SVN r18954
2014-06-17 11:22:34 +00:00
Doug Gregor
b9485466ff Add array forced downcast operations _arrayDownCast and _arrayBridgeFromObjectiveC.
Swift SVN r18952
2014-06-17 10:10:21 +00:00
Doug Gregor
c19b92e4b3 Rename array downcast entry points to have "conditional" in the name.
s/_arrayCheckedDownCast/_arrayDownCastConditional/g
s/_arrayBridgeFromObjectiveC/_arrayBridgeFromObjectiveCConditional/g



Swift SVN r18930
2014-06-16 15:06:04 +00:00
Dave Abrahams
e310fd7f0b [stdlib] Shed Array's vestigial copy and unshare
Swift SVN r18927
2014-06-16 14:11:37 +00:00
Dave Abrahams
c5c17e2615 [stdlib] Sort Arrays using bulk mutation backdoor
This results in a a massive speedup and could in principle be applied to
other bulk array mutations.

Swift SVN r18926
2014-06-16 14:04:54 +00:00
Dave Abrahams
9603472490 [stdlib] Add Array.withMutableStorage
This is our backdoor for efficient bulk in-place mutation of arrays
until uniqueness-check hoisting is available.

Swift SVN r18925
2014-06-16 14:04:53 +00:00
Dave Abrahams
85533dd7d3 [stdlib] Restore Array value semantics
'nuff said.

Swift SVN r18923
2014-06-16 13:56:15 +00:00
Dave Abrahams
acc2c3be40 [stdlib] Prepare array sort for value semantics
Sorting was a bit of a mess; we had sort functions doing in-place
mutation /and/ returing the value, and people were confused by the
asymmetry of Array's sort() method with other higher-level methods.

Fixes <rdar://problem/17185815> sort([]T, f) mutates the original array
<rdar://problem/17225190> The Array.sort() method should return a sorted array

Swift SVN r18922
2014-06-16 13:48:43 +00:00
Manman Ren
aec78d0693 [stdlib] revert r18764.
Swift SVN r18765
2014-06-10 00:13:41 +00:00
Manman Ren
cc90c81239 [stdlib] add two-operand version of max and use max2 in stdlib when appropriate.
This helps array append's performance by ~ 2x. The generic max with a variadic
argument creates a temporary array then iterates over the array.

rdar://17140639 rdar://17073827


Swift SVN r18764
2014-06-09 23:56:40 +00:00
Dave Abrahams
eab43d72d6 [emacs support] swift-mode: support break labels
Also use it to fix indentation in Arrays.swift.gyb

Swift SVN r18507
2014-05-21 20:08:26 +00:00
Dmitri Hrybenko
9a4004ab61 stdlib/Join: add forwarding join() instance functions to array and string types
rdar://16388632


Swift SVN r18493
2014-05-21 13:15:30 +00:00
Dmitri Hrybenko
652859f301 stdlib/Array: reduce duplication in ExtensibleCollection conformances
Swift SVN r18452
2014-05-20 12:45:03 +00:00
Dave Abrahams
418bec853f [stdlib] 1-character fix for Array.reserve
...plus the testing that makes that fix stick.  Fixes <rdar://16958865>

Swift SVN r18429
2014-05-19 21:20:48 +00:00
Dave Abrahams
fba449f83d [stdlib] Add an eager reverse() for Array
Swift SVN r18390
2014-05-19 04:40:39 +00:00
Dave Abrahams
5a4891a2db [stdlib] make Array.replaceRange be a method
By beating the compiler into submission with a "bouncing through
non-methods" method, I have made it accept my crazed intention that
Array and friends should interoperate with all Sequences and
Collections!  Filing <rdar://problem/16954833> to document the failure
of the method method.

Swift SVN r18378
2014-05-19 01:08:08 +00:00
Dave Abrahams
6dade3f1c8 [stdlib] Test Array.removeLast
Also improve its failure message

Swift SVN r18376
2014-05-19 00:36:37 +00:00
Dave Abrahams
1622fa5b9d [stdlib] assert => _precondition/_sanityCheck
Swift SVN r18374
2014-05-19 00:27:37 +00:00
Doug Gregor
bb95a324f9 Introduce new entry point _arrayBridgeFromObjectiveC for checked T[] -> U[] conversions.
This entry point is used when T is bridged verbatim and U is bridged
non-verbatim. It attempts to bridge each T from Objective-C to a U,
and returns nil if any of the elements cannot be bridged back to a U.

For now, only _convertNSArrayToArray and Array.bridgeFromObjectiveC
depend on this. It will soon be used for checked casts from, e.g.,
AnyObject[] to String[].

This is part of <rdar://problem/16952771> and general array bridging.

Swift SVN r18369
2014-05-18 23:44:27 +00:00
Dave Abrahams
8537f014bf [stdlib] Add lazy and Array filter algorithm
This came up during API review

Swift SVN r18364
2014-05-18 22:24:43 +00:00
Dave Abrahams
b763aedd47 [stdlib] Array API Review: privatization
Swift SVN r18339
2014-05-18 17:48:12 +00:00
Dave Abrahams
bec80488d0 [stdlib] Array API Review: insert:newElement:=>insert:AtIndex:
Swift SVN r18338
2014-05-18 17:43:16 +00:00
Dave Abrahams
69e1b1f515 [stdlib] Array API review: (new=>minimum)Capacity
Also some 80-column fixups

Swift SVN r18337
2014-05-18 17:39:31 +00:00
Dave Abrahams
200b89291c [stdlib] Array API review: privatize [bB]uffer
Swift SVN r18335
2014-05-18 17:32:00 +00:00
Dave Abrahams
8344b6dbb9 [stdlib] Array API Review: removeAt=>removeAtIndex
Swift SVN r18334
2014-05-18 17:32:00 +00:00
Dave Abrahams
5846923729 [stdlib] Array API review: popLast => removeLast
Swift SVN r18331
2014-05-18 17:03:38 +00:00
Dave Abrahams
68abebdffb [stdlib] withUnsafePointerToElements for Array
Also privatize ArrayType's elementStorage. Per Array API review.

Swift SVN r18330
2014-05-18 16:59:46 +00:00
Dave Abrahams
35d22e9ffb [stdlib] Array API Review: owner -> _owner
Swift SVN r18326
2014-05-18 15:58:15 +00:00
Dave Abrahams
92307dee66 [stdlib] Array API Review: swap init parameters
Swift SVN r18325
2014-05-18 15:54:33 +00:00
Dave Abrahams
3119144292 [stdlib] Array API Review: clear() -> removeAll()
Swift SVN r18324
2014-05-18 15:49:52 +00:00
Dave Abrahams
2746a7d558 Another Array bridge/cast test from Doug
Applied that same workaround for <rdar://problem/16953026> in one more
place.

Swift SVN r18321
2014-05-18 06:15:45 +00:00
Ted Kremenek
16dea15a24 Hide CocoaArray ('_' to mark as private API).
Swift SVN r18302
2014-05-18 04:03:32 +00:00
Doug Gregor
0aba627a86 Reinstate "Drive a wedge between array upcasts and array bridged
upcasts." 
Reinstate "Restrict the array-bridged conversion to non-verbatim
bridging." 
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC" 
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC" 
Reinstate "[stdlib] Move _arrayBridgedDownCast to Foundation"
 Reinstate "Replace "can" with "cannot" in a message." 
Reinstate "Implement support for non-verbatim T[] -> AnyObject[]
upcasts."  

This reinstates commit r18291. 
This reinstates commit r18290. 
This reinstates commit r18288. 
This reinstates commit r18287. 
This reinstates commit r18286. 
This reinstates commit r18293. 
This reinstates commit r18283.

John fixed the issue in r18294.


Swift SVN r18299
2014-05-18 03:36:09 +00:00
Michael Gottesman
263dca4b47 Revert "Drive a wedge between array upcasts and array bridged upcasts."
Revert "Restrict the array-bridged conversion to non-verbatim bridging."
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Move _arrayBridgedDownCast to Foundation"
Revert "Replace "can" with "cannot" in a message."
Revert "Implement support for non-verbatim T[] -> AnyObject[] upcasts."

This reverts commit r18291.
This reverts commit r18290.
This reverts commit r18288.
This reverts commit r18287.
This reverts commit r18286.
This reverts commit r18293.
This reverts commit r18283.

Sorry for the number of reverts, but I needed to do this many to get a clean
revert to r18283.

Swift SVN r18296
2014-05-18 02:42:56 +00:00
Doug Gregor
323ac07bf1 Replace "can" with "cannot" in a message.
Swift SVN r18293
2014-05-18 01:30:03 +00:00
Dave Abrahams
5fd71e0cca [stdlib] Move _arrayBridgedDownCast to Foundation
That's the only place it's used, as a helper.  Next up: correct the
semantics

Swift SVN r18286
2014-05-18 00:25:55 +00:00
Doug Gregor
df657180f4 Implement support for non-verbatim T[] -> AnyObject[] upcasts.
One of my recent type-checker changes starting passing all array
upcasts, including "bridged" ones like String[] -> AnyObject[],
through the library entry point _arrayUpCast, which is only meant for
class/ObjC existential types that are bridged verbatim.

Fixes part of <rdar://problem/16952238>; more cleanup to follow.

Swift SVN r18283
2014-05-17 23:27:44 +00:00
Ted Kremenek
26320dc0ed Per API review, rename 'reserve' to 'reserveCapacity'.
Swift SVN r18272
2014-05-17 21:00:28 +00:00