Commit Graph

60 Commits

Author SHA1 Message Date
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
Doug Gregor
bed81488c1 Revert r18232, r18220: we're not doing T* now.
Swift SVN r18250
2014-05-17 16:36:02 +00:00
Dave Abrahams
d6e4964ace [stdlib] Make _convertNSArrayToArray meet spec
I believe this correctly implements the "forced conversion" part of the
Arrays.rst document.

Swift SVN r18248
2014-05-17 14:08:33 +00:00
Dave Abrahams
2fc6414b5d [stdlib/Array] Improve another comment
Swift SVN r18245
2014-05-17 06:25:56 +00:00
Dave Abrahams
6b0c79a0f2 [stdlib/Array] Eliminate or label unused functions
Swift SVN r18244
2014-05-17 06:25:56 +00:00
Dave Abrahams
f57c2b8e47 [stdlib] Remove unused functions
Swift SVN r18240
2014-05-17 05:33:26 +00:00
Doug Gregor
73f02d1a69 Switch a bunch of UnsafePointer<T>'s over to T*
Swift SVN r18220
2014-05-16 22:32:01 +00:00
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Doug Gregor
b756fc29ec Don't require paretheses when mixing optional types and array types...
... unless we actually hit one of the confusing cases involving
multi-dimensional arrays (e.g., Int[]?[]), at which point one needs to
write parentheses <rdar://problem/16737035>.



Swift SVN r18181
2014-05-16 06:03:26 +00:00
Ted Kremenek
172cc3c984 Fix my last commit to accommodate for rename of NativeArray.
Swift SVN r18151
2014-05-16 00:45:48 +00:00