Commit Graph

1309 Commits

Author SHA1 Message Date
Maxwell Swadling
b3253f7651 [stdlib] Changed uintValue to a var
Fixes rdar://problem/18469215

Swift SVN r24118
2014-12-23 20:11:51 +00:00
Maxwell Swadling
02808373d8 [stdlib] Fixed bugs with string views
Fixes rdar://problem/18435682
Fixes rdar://problem/19238102

Swift SVN r24117
2014-12-23 20:02:38 +00:00
Dave Abrahams
7d50db0cec [stdlib] String index mapping: finish tests
Doc comments are next.

Swift SVN r24070
2014-12-22 15:30:57 +00:00
Dave Abrahams
f78b6b125a [stdlib] Conversions to String.Index
Also, hide an initializer on String.Index that was unintentionally
public/visible by giving it an underscored keyword argument.

Testing comes next.

Swift SVN r24069
2014-12-22 15:30:56 +00:00
Dave Abrahams
d6bdfc1cfe [stdlib] Finish tests for current String index conversions
Also clean unused detritus and anacrhonisms from testing code.

Tests for the currently-implemented conversions were incomplete, but are
now done.

Swift SVN r24068
2014-12-22 05:40:57 +00:00
Dave Abrahams
a9d7577b5f [stdlib] conversions to String.UnicodeScalarIndex
Also expanded testing to include checking translation of end indices
between views.

Swift SVN r24067
2014-12-22 01:13:46 +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
Chris Lattner
b8596ffccb move the stdlib to the new syntax for @autoclosure attribute.
Swift SVN r24048
2014-12-20 00:16:36 +00:00
Dave Abrahams
2cd5290005 [stdlib] Add some missing doc comments
Swift SVN r24038
2014-12-19 19:48:37 +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
Dave Abrahams
43ea3db04e [stdlib] conversions to UTF16View.Index
Swift SVN r24013
2014-12-18 20:47:38 +00:00
Dave Abrahams
386146364b [stdlib] Refactor String.UTF8Index for conversion
The old design did not strictly keep track of the index in underlying
UTF16, which would have made converting between the different index
types too difficult.  It also made equality comparison between indices
broken, because

  UTF8Index(s.utf16.startIndex+1, within: s.utf8)

and

  UTF8Index(s.utf16.startIndex, within: s.utf8).successor()

would often have completely different UTF8 buffers and offsets within
the underlying UTF16.

For some reason this disturbed SILPasses/devirt_default_case.swift,
which is now XFAIL'd.  <rdar://problem/19298212>
SILPasses/devirt_default_case.swift is XFAIL'd

Swift SVN r24012
2014-12-18 20:47:37 +00:00
Dave Abrahams
3c9c3fa457 [stdlib] conversions to String.UTF8Index
Swift SVN r24011
2014-12-18 20:47:35 +00:00
Dave Abrahams
27983cf144 [stdlib] typealiases for String Indexes
Just a convenience

Swift SVN r24010
2014-12-18 20:47:34 +00:00
Dave Abrahams
e85a03663f [stdlib] String.UTF16View.Index speedups
Even though it doesn't conform to RandomAccessIndexType without
Foundation loaded, we can implement these internal operations to happen
in O(1), which, e.g., should speed up count(s.utf16) among others.

Swift SVN r24009
2014-12-18 20:47:33 +00:00
Andrew Trick
c2f3622ac3 Revert "Mark _copyCollectionToNativeArrayBuffer readonly."
This reverts commit 71eb477aa6d9354cbad7baebae4283936bb1831a.

Per Erik's review.
The correct fix is interprocedural analysis that has visibility
into specialized functions. Let's just wait for that.

Swift SVN r24007
2014-12-18 18:22:01 +00:00
Dmitri Hrybenko
555e0d2d2b stdlib/Hashing: add a comment explaining why the variable is defined in
C++ code

Swift SVN r23999
2014-12-18 00:24:54 +00:00
Maxwell Swadling
c2aa030c29 [stdlib] Specialized String's Generator
Specializing String's Generator yields a significant performance
improvement.

Swift SVN r23998
2014-12-18 00:12:32 +00:00
Maxwell Swadling
7cc8dfd59d [stdlib] made IndexingGenerator._elements a let
The elements of a collection can never be mutated by the Generator.

Swift SVN r23997
2014-12-18 00:12:30 +00:00
Dmitri Hrybenko
9177107940 stdlib/Hashing: move the hash seed variable to C++ code to avoid
dispatch_once calls on every load from it

Performance improvements, as reported by the perf testing buildbot:

Histogram       -18.81%
TwoSum          -17.42%
RGBHistogram    -9.65%

Regressions:

InsertionSort                5.59%
ArrayOfRef                   3.99%
SwiftStructuresInsertionSort 5.29%
PrimeNum                     6.09%

These regressions are bogus.  The tests that "regressed" don't do any
hashing at all.

Swift SVN r23995
2014-12-17 23:45:29 +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
Dave Abrahams
ada079bb4d [stdlib] UTF16View: unavailable subscript with Int
There had been some discussion of making this available iff Foundation
is loaded, but it turns out that there are almost no Foundation APIs
that return NSUInteger indices into NSStrings without first packaging
them into NSRanges, and when <rdar://problem/19255291> is addressed,
these NSRanges will become Swift Range's, which have a different
interface.  So there's no seamless API transition to be had here, for
any substantial subset of code written against Cocoa.

Swift SVN r23949
2014-12-15 22:24:31 +00:00
Andrew Trick
361ceea369 Mark _copyCollectionToNativeArrayBuffer readonly.
This fixes one of the issues preventing optimization of RangeAssignment
when it isn't fully inlined. There is still another problem with this benchmark I haven't fixed:
<rdar://problem/19252374> We fail to fully optimize RangeAssignment. Forced inlining achieves 3-4x speedup.

This fix at least unblocks CopyForwarding, which perturbs inlining enough to expose the issue.

Swift SVN r23944
2014-12-15 21:20:03 +00:00
Dmitri Hrybenko
e87bcff79d stdlib: move String.{lowercaseString,uppercaseString} to the core
library

Swift SVN r23936
2014-12-15 09:47:03 +00:00
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Dmitri Hrybenko
b169a102f7 stdlib: coding style: use "SPI(module)" annotation
Swift SVN r23931
2014-12-15 03:36:02 +00:00
Dave Abrahams
9550c02956 [stdlib] String.UTF16View.Index is bidirectional
Rather than expose random access on String.UTF16View to all Swift users,
expose it only when Foundation is loaded.  This effectively decouples
String from a UTF16 representation on non-Mac platforms.

Swift SVN r23929
2014-12-14 17:11:04 +00:00
Dave Abrahams
67ebc83674 [stdlib] String.UTF16View.Index is no longer Int
We don't want to be locked into a UTF-16 representation on all
platforms, and when we implement String index conversion we really don't
want to extend the interface of Int.

Swift SVN r23928
2014-12-14 17:11:03 +00:00
Maxwell Swadling
63462e64d0 [stdlib] Added ASCII fast path for string hashing
Swift SVN r23896
2014-12-12 22:22:58 +00:00
Erik Eckstein
14af3a57e8 Enable elimination of dead methods which are in classes of higher visibility.
The underlying problem is that e.g. even if a method is private but its class is public, the method can be referenced from another module - from the vtable of a derived class.
So far we handled this by setting the SILLinkage of such methods according to the visibility of the class. But this prevented dead method elimination.
Now I set the SILLinkage according to the visibility of the method. This enables dead method elimination, but it requires the following:
1) Still set the linkage in llvm so that it can be referenced from outside.
2) If the method is dead and eliminated, create a stub for it (which calls swift_reportMissingMethod).



Swift SVN r23889
2014-12-12 17:35:40 +00:00
Maxwell Swadling
3fd1eb23c4 [stdlib] Fixed typo in Character comment
Swift SVN r23847
2014-12-10 23:24:43 +00:00
Maxwell Swadling
4d1ebdbf1b [stdlib] fixed character ASCII fastpath
Swift SVN r23845
2014-12-10 19:13:25 +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
Joe Groff
dc4ada34ff Revert "Fix doc comment for ObjectIdentifier.uintValue"
This reverts commit r23742. Brain fart on my part.

Swift SVN r23746
2014-12-05 22:58:46 +00:00
Joe Groff
ee5adc1f6e Runtime: Provide reflection for metatypes.
Metatypes have no user-visible structure, but can at least summarize as their type names. This gives us reasonable ad-hoc Printable behavior (thought debugPrint is still wrong, since a type name isn't parsable without being .self'ed).

Swift SVN r23745
2014-12-05 22:58:44 +00:00
Joe Groff
1cf1b4172b Runtime: Use full demangled names when reflecting values.
Use the recursive demangled name generation I implemented in _typeName for metatypes in _stdlib_getDemangledType as well, so that we get fully-qualified generic names and other goodness.

Swift SVN r23743
2014-12-05 21:25:50 +00:00
Joe Groff
c744c5ec30 Fix doc comment for ObjectIdentifier.uintValue
Identifier equality is equivalent to identity, not value equality.

Swift SVN r23742
2014-12-05 21:25:49 +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
Maxwell Swadling
2eda5a2341 [stdlib] added ASCII fast path to Character
Swift SVN r23705
2014-12-05 00:24:37 +00:00
Maxwell Swadling
d749871b55 [stdlib] Added comment on incorrect unicode compare
Swift SVN r23703
2014-12-05 00:24:31 +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