Commit Graph

30 Commits

Author SHA1 Message Date
Dmitri Hrybenko
311957061a Stop using Unsafe[Mutable]Pointer.null()
This API will be removed per rdar://19159145 (it is redundant with nil
literals and the default initializer).

Swift SVN r24795
2015-01-28 08:42:26 +00:00
David Farler
7339a8056b Set: remove workaround for 18803556 when iterating over Sequences
Swift SVN r24719
2015-01-25 09:00:42 +00:00
Maxwell Swadling
374df28991 Revert "[stdlib] Set automaticallyNotifiesObserversForKey to false"
Adding this complexity does not offer any significant improvements.

This reverts commit r24467.
Git commit: c17e2294e4e100bfc44efe792523c314a38cec47.

Swift SVN r24481
2015-01-16 22:47:44 +00:00
Andrew Trick
e2760a7036 Add a return statement to Variant[Set|Dictionary]Storage.removeAtIndex.
This fast path is only taken when the code is specialized.
Fixes <rdar://problem/19331717> Optimizer breaks Set<T> and Dictionary<K, V>

Swift SVN r24479
2015-01-16 21:10:48 +00:00
Maxwell Swadling
92e55287aa [stdlib] Set automaticallyNotifiesObserversForKey to false
automaticallyNotifiesObserversForKey is now false for Array, Dictionary
and Set (since they can not be mutated).

Fixes rdar://problem/19404025

Swift SVN r24467
2015-01-16 01:25:51 +00:00
David Farler
280d212c78 Set: print different forms for description and debugDescription
Set.description now prints its array literal form, and
Set.debugDescription prints its initializer form. Both print
the debugDescription of the members.

Set([1,2,3]).description = "[2, 3, 1]"
Set([1,2,3]).debugDescription = "Set([2, 3, 1])"

rdar://problem/19312961

Swift SVN r24306
2015-01-09 10:09:40 +00:00
Dmitri Hrybenko
9efbdb8278 stdlib/HashedCollections: mark some APIs @testable
The mandatory inlining of generic functions simplifies code and the
compiler omits these symbols now, so they could not be used in tests.

Swift SVN r24296
2015-01-09 03:53:34 +00:00
Maxwell Swadling
21fd60fd92 [stdlib] added fast getObjects:andKeys:
Improved performance of some bridged dictionary operations
Fixes rdar://problem/18873563

Swift SVN r24293
2015-01-09 02:09:53 +00:00
David Farler
87c3d7421f Refine static func and var syntax
rdar://problem/17198298

- Allow 'static' in protocol property and func requirements, but not 'class'.
- Allow 'static' methods in classes - they are 'class final'.
- Only allow 'class' methods in classes (or extensions of classes)
- Remove now unneeded diagnostics related to finding 'static' in previously banned places.
- Update relevant diagnostics to make the new rules clear.

Swift SVN r24260
2015-01-08 03:03:29 +00:00
Maxwell Swadling
7fc1ad679a [stdlib] fixed incorrect deinitialization in Dictionary
Dictionary could be double freed after bridging to ObjC due to a call to
takeRetainedValue(), causing a segfault. This was fixed by removing the
free call, as it was unnecessary.

Fixes rdar://problem/18544533

Swift SVN r24208
2015-01-06 03:36:54 +00:00
Dmitri Hrybenko
4f819a9cf7 Remove an NSSet.copyObjectPointers() API that was unintentionally added
Swift SVN r24054
2014-12-20 03:01:34 +00:00
Maxwell Swadling
b6cd6ebda8 [stdlib] Removed bidirectional iterator from Dictionary and Set
Swift SVN r24023
2014-12-19 00:22:15 +00:00
David Farler
1766dd71ed Use Set([...]) as Set's description, debugPrint elements
Don't use {. . .} as Set's description - use:

Set([1, 2, 3]) and debugPrint the elements.

rdar://problem/19299943

Swift SVN r24021
2014-12-19 00:01:38 +00:00
Dmitri Hrybenko
e5c3b534fe stdlib/HashedCollections: don't save the NativeStorage in a local
variable

We were avoiding recomputing it because it used to be a slow operation.

Performance improvements, as reported by the perf testing buildbot:

Histogram                 -14.07%
StringUtilsUnderscoreCase -10.22%
Dictionary                -10.75%
LevenshteinDistance       -18.08%

Regressions:

* ArraySubscript 8.56%
  This is just bogus.  That test does not do any hashing.

* NSDictionaryCastToSwift 6.86%
  This test does not do any hashing.  It operates only on empty
  dictionaries.  I believe this is noise.

Swift SVN r23991
2014-12-17 22:17:59 +00:00
David Farler
324411a44b Don't trap when creating a Set from a literal with duplicate elements
rdar://problem/19178760

Swift SVN r23791
2014-12-08 23:09:04 +00:00
David Farler
16633eac05 Rename any/removeAny to first/removeFirst
Sticking with the original design.

Also added a trap test for removeFirst() since its precondition
is that the set be non-empty, similar to Array.

Swift SVN r23712
2014-12-05 01:42:45 +00:00
David Farler
e7506e8eab Remove underscore from _Set<T>
rdar://problem/19132138

Make Set<T> visible by removing the underscore. Also, remove the pesky
${_Self} gyb variable that was for a temporary convenience in hiding Set.

Swift SVN r23699
2014-12-05 00:21:35 +00:00
David Farler
ad67a452dc Set.any should be a method
Although Set.any will always return the same element when not modifying
the set, that is an implementation detail. It should be a method.

Swift SVN r23697
2014-12-05 00:01:21 +00:00
David Farler
e1dd3bad59 Set: Rename removeFirst -> removeAny and first -> any
Rename in Set<T>:

func removeFirst() -> T
to
func removeAny() -> T?

var first: T?
to
var any: T?

- FWIW, `any` more closesly matches NSSet's `anyObject()` and constructs
  in other languages, so `first` seems to be a bit of a surprise.
- `first` implies an ordering of some kind, iterating over `Set` as a
  `SequenceType` does have a somewhat reliably "first" element, but it
  also has a linguistic tension with the fact that Set<T> is
  semantically unordered.
- `first` may be further confused if there ever is an OrderedSet<T>,
  which ought to be the first element in its semantic ordering.

Swift SVN r23696
2014-12-04 23:54:57 +00:00
David Farler
419afc489b Add performance FIXME for Set.intersect
Swift SVN r23675
2014-12-04 02:12:07 +00:00
David Farler
85f300609b Add exclusiveOr, exclusiveOrInPlace to Set<T>
rdar://problem/19124388

Swift SVN r23674
2014-12-04 02:06:19 +00:00
David Farler
76c5937b6c Build fix: Don't invalidate Set index during intersect
Intersect needs an intermediate set because we need to both traverse
and modify the left-hand side for the in-place operation, which can
invalidate the index.

Swift SVN r23666
2014-12-04 00:28:48 +00:00
David Farler
f9eb39cee3 Remove Comparable from Set<T>
Swift SVN r23663
2014-12-03 23:16:27 +00:00
David Farler
6757a7d7f6 Commit next revision of Set<T> public API
The public API is mostly solid at this point, with only a few minor
changes to naming and a couple of extra methods to bring it to parity
with Array.

Also removed the quick-and-dirty operators <, >, <=, and >= which were
used as a convenient shorthand for strict subset, strict superset,
subset, and superset respectively (< is retained for Comparable
conformance).

Swift SVN r23657
2014-12-03 22:22:24 +00:00
David Farler
7493240117 Add any() -> T? to Set
rdar://problem/19062929

Swift SVN r23599
2014-12-01 22:08:51 +00:00
Joe Groff
b60a30c84b stdlib: Make isUniquelyReferenced shims properly return bool.
rdar://problem/18573806 is fixed.

Swift SVN r23547
2014-11-22 05:36:38 +00:00
David Farler
2539ebdabf <rdar://problem/18979003> _Set([1,2,3]) crashes in Xcode playground: assertion in IDEPlaygroundQuickLookForStructure.m:405
Swift SVN r23319
2014-11-14 02:32:35 +00:00
Dmitri Hrybenko
4cd60e6b4e stdlib/Set: add #if guards for non-ObjC platforms
Swift SVN r23266
2014-11-12 09:05:39 +00:00
David Farler
d0718c69fc Prefix Set<T> with underscore for API development
Swift SVN r23263
2014-11-12 07:07:01 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00