Commit Graph

129 Commits

Author SHA1 Message Date
Patrick Pijnappel
4aa89978d2 [stdlib] Fix typos 2015-12-13 21:35:53 +11:00
Arnold Schwaighofer
8f225da5ca Also use array semantics for the array element get function on non-objc systems
... and we hoist uniqueness checks for array on linux.

rdar://23865507
2015-12-11 17:15:15 -08:00
Arnold Schwaighofer
d5b3bfbd59 ArraySemantics: Add an api to replace a call to _getElement with a value
Also remove dependent calls to hoistableNativeTypeCheck() and checkSubscript()
calls. To find the guarding checkSubscript() call we introduce a return value to
checkSubscript that is used by the _getElement() call so that we can just follow
the use-def chain to find the dependence.
2015-12-08 07:34:25 -08:00
Arnold Schwaighofer
4b22a31154 ArraySemantics: Remove getArrayPropertyIsNative - we are only using
hoistableIsNativeTypeChecked these days.
2015-12-08 07:34:25 -08:00
Kanstantsin Linou
c9024ccc2c Fix typo in Arrays.swift.gyb
<code>accross</code> -> <code>across</code>
2015-12-08 17:39:28 +03:00
rajkumarpunchh
7a7efeb3cd Fixed Typo. “forumula” to “formula”. 2015-12-08 17:05:10 +05:30
Alfredo Delli Bovi
e437c4557c Fix typo in comments 2015-12-05 15:34:45 +01:00
Patrick
14fdf744b0 Make documented complexity consistent
Since most of the documentation in the code use O(`self.count`) instead of O(`count`), change the inconsistent code documentation to O(`self.count`).
2015-12-04 17:15:55 -08:00
Jordan Rose
cf8baedee2 Re-apply "Rename @transparent to @_transparent for now."
This re-applies 90fcbfe9a6. I'll be committing
the corresponding change to Foundation momentarily.
2015-11-16 10:53:56 -08:00
Xin Tong
16843684b2 Revert "Rename @transparent to @_transparent for now."
This reverts commit 90fcbfe9a6.

Seems there are still some tests that are left not modified.
2015-11-14 07:04:31 -08:00
Jordan Rose
90fcbfe9a6 Rename @transparent to @_transparent for now.
This feature has not been fully designed, let alone properly implemented.
For more information, see docs/TransparentAttr.rst.
2015-11-13 16:25:34 -08:00
David Farler
8f2fbdc93a Make function parameters and refutable patterns always immutable
All refutable patterns and function parameters marked with 'var'
is now an error.

- Using explicit 'let' keyword on function parameters causes a warning.
- Don't suggest making function parameters mutable
- Remove uses in the standard library
- Update tests

rdar://problem/23378003
2015-11-09 16:56:13 -08:00
Erik Eckstein
971a680199 Support for stack promotion of array buffers in the stdlib.
The basic idea is to move the allocation of the buffer out of @_semantics("array.uninitialized") so that it can be inlined without inlining the semantics function (on high-level SIL).

This change in the stdlib also requires an adaption of the dead area elimination in DeadObjectElimination.
Otherwise it would just remove the semantics function but not the allocation and we would leak memory.
2015-11-05 16:52:59 -08:00
Dave Abrahams
912a00cfad [stdlib] More Array Refactoring
w/Dmitri and Arnold, making incremental progress towards comprehensible
code.

Swift SVN r32716
2015-10-16 00:08:03 +00:00
Dave Abrahams
06e32293a4 [stdlib] Attempt to fix linux build
An Array's buffer is a ContiguousArrayBuffer on Linux.

Swift SVN r32323
2015-09-29 23:52:24 +00:00
Dave Abrahams
243b528fac [stdlib] Array refactoring: simplify all array subscript checking
Swift SVN r32314
2015-09-29 22:38:59 +00:00
Dave Abrahams
cfe877bc0a [stdlib] Array refactoring: s/hoistedIs/was/
Swift SVN r32312
2015-09-29 22:38:57 +00:00
Dave Abrahams
b1e98fe3e1 [stdlib] Array refactoring: s/NoTypeCheck/TypeChecked/
First in a long series of commits to clean up the array implementation
and make it maintainable by the stdlib team.

Swift SVN r32311
2015-09-29 22:38:56 +00:00
Dave Abrahams
5cf32911fb Array: Improve function, parameter names and add documentation
NFC.

Swift SVN r32310
2015-09-29 22:38:53 +00:00
Arnold Schwaighofer
599a438015 Don't force to grow the buffer everytime we make it unique
rdar://22873620

Swift SVN r32280
2015-09-28 20:47:23 +00:00
Dmitri Hrybenko
2ff89aa40e stdlib: fix comment on ArraySlice.startIndex
ArraySlice.startIndex is not necessarily zero anymore.

rdar://22633052

Swift SVN r31921
2015-09-14 05:40:14 +00:00
Arnold Schwaighofer
aeece6bc1f stdlib: DRY and disable inlining of code to curb code growth
This halves the code size of array append inlined into user code.

Swift SVN r31603
2015-09-01 16:45:05 +00:00
Arnold Schwaighofer
314e5d9378 stdlib: Remove dead code
Swift SVN r31602
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
55e4795972 stdlib: Fix formatting.
Swift SVN r31601
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
de90e57428 stdlib: Reformulate to make ARC's job easier
The extra control-flow seems to inhibit ARC and we end up with an extra
retain-release regressing LevenshteinDistance by 40%.

rdar://22479186

Swift SVN r31588
2015-08-31 18:02:12 +00:00
Arnold Schwaighofer
9fd52b9123 stdlib: Instead of calling reserveCapacity in Array.init(_uninitializedCount)
directly construct a buffer of the right size

This safes a uniqueness check and unecessary code bloat when inlining
reserveCapacity.

rdar://22446738

Swift SVN r31540
2015-08-27 20:07:07 +00:00
Dmitri Hrybenko
6360a590b5 Revert "Fix a problem where the legacy Mirror for ArraySlice would cause an out-of-bounds access if the slice is not zero-based"
This reverts commit r31398.  The commit does not have tests and
introduces code duplication.

Swift SVN r31408
2015-08-22 08:04:51 +00:00
Enrico Granata
fe27790126 Fix a problem where the legacy Mirror for ArraySlice would cause an out-of-bounds access if the slice is not zero-based
rdar://problem/22373053



Swift SVN r31398
2015-08-21 23:08:47 +00:00
Dmitri Hrybenko
d6f04ade75 stdlib: convert join() into a protocol extension
Part of rdar://22022419

Swift SVN r31186
2015-08-12 21:16:25 +00:00
Arnold Schwaighofer
afe39b3c1a Allow hoisting of uniqueness check in array.append
At -O I see about 10% improvement on Havlak, and 40% improvement on the recently
added array append benchmarks.

COWTree regresses by 15% because we hoist an append that is conditionally
executed. If we were to disallow hoisting of conditionally executed benchmarks
we would see big loses accross our benchmarks (for example, we would not hoist
out of nested loops anymore). So we will have to live with this regression.

rdar://17140639

Swift SVN r31120
2015-08-10 20:40:20 +00:00
David Farler
9f10b691e6 Reviewed: Containers should use debug description of their elements in both description and debugDescription
- Don't need CollectionOfOne.description
- Don't use private functions for shared internal functions for
  constructing descriptions

Swift SVN r31071
2015-08-07 08:52:35 +00:00
David Farler
9aa7663ad3 Always debugPrint containers' elements
rdar://problem/19312992

Swift SVN r31067
2015-08-07 06:14:19 +00:00
Dmitri Hrybenko
dd3194a18c stdlib: adopt @warn_unused_result
rdar://20957486

Swift SVN r31048
2015-08-06 14:53:18 +00:00
Joe Pamer
828eb68e72 Commit DaveA's API changes to 'print', along with the compiler changes necessary to support them.
There's still work left to do. In terms of next steps, there's still rdar://problem/22126141, which covers removing the 'workaround' overloads for print (that prevent bogus overload resolution failures), as well as providing a decent diagnostic when users invoke print with 'appendNewline'.

Swift SVN r30976
2015-08-04 01:57:11 +00:00
Dmitri Hrybenko
9a77d843da stdlib: update references to 'isEmpty' in comments
Swift SVN r30954
2015-08-03 19:22:57 +00:00
David Farler
034d0cfbf0 Fix three-way mid-air collision around Array buffers and RangeReplaceable tests
Swift SVN r30843
2015-07-31 04:43:03 +00:00
David Farler
f924e8e007 ArraySlice indexes no longer zero-based
ArraySlice indices now map directly onto the collection it is slicing
and maintains that mapping even after mutations.

Before:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 0..<5
s[0] = 111
s                // [111, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 1..<5

After:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 5..<10
s[5] = 99
s                // [99, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 6..<10

- Refactor some of the internals of the buffer types to make it easier
  to read and understand.
- Add Array, ArraySlice, and ContiguousArray to the test suite at the
  RangeReplaceable test entry points, subjecting them to the same tests
  as all of our collections.
- Update existing test expectations for the indexing changes.

rdar://problem/21866825

Swift SVN r30840
2015-07-31 03:25:29 +00:00
Dmitri Hrybenko
61b93564e9 Eliminate UnsafeMutableBufferPointer from _withUnsafeMutableBufferPointerIfSupported
The type checker hits a recursion when checking the conformance to
CollectionType in UnsafeMutableBufferPointer, which requires
_withUnsafeMutableBufferPointerIfSupported, which mentions
UnsafeMutableBufferPointer.  The easiest fix for now is to break the
recursion in the library.

Reverting this change is tracked by: <rdar://problem/21933004> Restore
the signature of _withUnsafeMutableBufferPointerIfSupported() that
mentions UnsafeMutableBufferPointer

Swift SVN r30838
2015-07-31 03:21:54 +00:00
Joe Groff
1d49d927e1 stdlib: Mark many higher-order function interfaces as 'rethrows'.
This covers:

- Lifetime-extending wrappers, like withExtendedLifetime, withCString, and withUnsafe*Pointer
- 'map' and friends on Optional
- 'indexOf'

A few APIs I haven't gotten to yet in this first pass:

- Autoclosure APIs, like assert, &&, etc.
- the 'isOrderedBefore' predicate for sorting APIs. The sorting implementation does some microoptimizations with 'inout' closures that violate rethrows checking.
- Strict 'map', 'filter', and friends on CollectionType. These need some plumbing in Lazy to be able to thread a Result-forming transformation through.

This version of the patch updates some protocol customization implementations that I missed the first time around, and includes the tests I forgot to add in the previous iteration.

Swift SVN r30790
2015-07-30 05:28:17 +00:00
Dmitri Hrybenko
d97ac3e64c stdlib: rename RangeReplaceableCollectionType.extend() to appendContentsOf()
rdar://21972324

Swift SVN r30607
2015-07-25 00:36:37 +00:00
Joe Groff
b0ec0d6da4 Revert "stdlib: Mark many higher-order function interfaces as 'rethrows'."
This reverts commit r30597, to help detangle it from other potentially-breaking changes that landed
on the bots simultaneously.

Swift SVN r30602
2015-07-24 23:31:59 +00:00
Joe Groff
4be02cab5b stdlib: Mark many higher-order function interfaces as 'rethrows'.
This covers:

- Lifetime-extending wrappers, like withExtendedLifetime, withCString, and withUnsafe*Pointer
- 'map' and friends on Optional
- 'indexOf'

A few APIs I haven't gotten to yet in this first pass:

- Autoclosure APIs, like assert, &&, etc.
- the 'isOrderedBefore' predicate for sorting APIs. The sorting implementation does some microoptimizations with 'inout' closures that violate rethrows checking.
- Strict 'map', 'filter', and friends on CollectionType. These need some plumbing in Lazy to be able to thread a Result-forming transformation through.

Swift SVN r30597
2015-07-24 22:52:23 +00:00
Ted Kremenek
771761f9f6 Re-apply "stdlib: eliminate unused typealias and tidy up the doc comment""
This reverts commit r30468.

It's not clear if the original commit caused a build regression, but it appears to be resolved now.

Swift SVN r30469
2015-07-21 22:30:59 +00:00
Ted Kremenek
3f41e175b3 Revert "stdlib: eliminate unused typealias and tidy up the doc comment"
This reverts commit r30458.

This is breaking test 'Swift :: stdlib/Algorithm.swift.gyb'

Swift SVN r30468
2015-07-21 22:10:21 +00:00
Dmitri Hrybenko
8d4866ae9b stdlib: eliminate unused typealias and tidy up the doc comment
Swift SVN r30458
2015-07-21 20:40:37 +00:00
Joe Groff
6608221a72 stdlib: Remove _UnitTestArray.
rdar://problem/20246497

Swift SVN r30348
2015-07-18 00:14:28 +00:00
David Farler
241de1a1c3 Add popFirst/popLast implementations for some collections
Add the following non-customizable implementations:

- popFirst/popLast for Collections whose SubSequence == Self.
- Array.popLast
- ContiguousArray.popLast
- Set.popFirst
- Dictionary.popFirst

Swift SVN r30278
2015-07-16 22:52:05 +00:00
Mark Lacey
da983196a3 Add a specialization of extend for collections.
The specialization uses += operator for collections, which performs much
better than the += operator for sequences.

The extend benchmark from rdar://problem/21689050 improves by:
- 2500x with -O
- 15x with -O -whole-module-optimization

Unfortunately we still seem to be about 100x slower than the user's
memcpy version of the same benchmark with -O -whole-module-optimization.

Swift SVN r30033
2015-07-09 18:28:03 +00:00
Mark Lacey
9c713556d7 Remove a work-around from extend().
The test case in the radar appears to compile without issue now, and
moving this code back inline appears to work.

Swift SVN r29992
2015-07-08 20:56:08 +00:00
Dave Abrahams
fb241acf6f [stdlib] kill __ArrayType
Swift SVN r29895
2015-07-02 18:47:05 +00:00