Commit Graph

112 Commits

Author SHA1 Message Date
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
43ea3db04e [stdlib] conversions to UTF16View.Index
Swift SVN r24013
2014-12-18 20:47:38 +00:00
Dave Abrahams
3c9c3fa457 [stdlib] conversions to String.UTF8Index
Swift SVN r24011
2014-12-18 20:47:35 +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
Maxwell Swadling
63462e64d0 [stdlib] Added ASCII fast path for string hashing
Swift SVN r23896
2014-12-12 22:22:58 +00:00
Maxwell Swadling
d749871b55 [stdlib] Added comment on incorrect unicode compare
Swift SVN r23703
2014-12-05 00:24:31 +00:00
Graham Batty
7ed843aab9 Revert "Implement String Comparable and Hashable conformances for non-objc"
This reverts commit 6d086ae7fe6725c74924ff410c562949a286e7d1.

Swift SVN r23576
2014-11-24 17:42:05 +00:00
Graham Batty
396eca75b4 Implement String Comparable and Hashable conformances for non-objc
This is just a basic implementation of each, with some questions
lingering about whether to do unicode normalization (and if so how),
but it gets things going.

Swift SVN r23572
2014-11-24 17:40:24 +00:00
Maxwell Swadling
530ae1777a Added ASCII fast paths for common string operations
- ==, <, lowercaseString and uppercaseString on String now have ASCII fast paths
- Fixes rdar://problem/17962640

Swift SVN r23494
2014-11-21 00:07:32 +00:00
Graham Batty
dc6a776d10 stdlib: Use config directives to work without objective-c.
Swift SVN r23211
2014-11-10 20:06:25 +00:00
Graham Batty
373414864d Revert "Use config directives to carve out a 'portable' kernel stdlib."
This reverts commit r23202 pending further discussion.

Swift SVN r23205
2014-11-10 18:46:42 +00:00
Graham Batty
dfa260fab1 Use config directives to carve out a 'portable' kernel stdlib.
Swift SVN r23202
2014-11-10 18:03:09 +00:00
Dave Abrahams
44c0ab4385 [stdlib] Internal protocol renaming
for consistency with earlier moves on NSArray shadow protocols

Swift SVN r22908
2014-10-24 15:48:44 +00:00
Erik Eckstein
b51b3ed123 Mark public compiler intrinsics with // COMPILER_INTRINSIC
I followed Joe's example in Process.swift and used COMPILER_INTRINSIC (and not just INTRINSIC)



Swift SVN r22723
2014-10-14 07:32:03 +00:00
Dave Abrahams
57367877c4 [stdlib] Make 'Character' a struct
It used to be a public enum, which unnecessarily exposed structure that
was intended to be private implementation detail.  This change also has
the benefit that converting a String to a Character will avoid
allocating memory in many more cases.

Swift SVN r22629
2014-10-09 18:25:25 +00:00
Erik Eckstein
60dcb9a435 Make compiler intrinsics public (part 2).
With the changed SILLinkage and dead function removal of internal functions this is necessary.



Swift SVN r22490
2014-10-03 13:58:50 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Dmitri Hrybenko
a04ee3a463 stdlib/Unicode: allow transcode() to operate on mutable value-typed
sinks

Swift SVN r22302
2014-09-26 17:28:00 +00:00
Dave Abrahams
a7f3e4222e [stdlib] finish public non-protocol docs
The 58 undocumented public non-operator APIs still present in core are
all on non-exposed (underscored) APIs.

Swift SVN r22263
2014-09-24 12:31:45 +00:00
Dave Abrahams
795799b0d2 [stdlib] Propagate Hashable docs
202 undocumented public non-operator APIs remain in core

Swift SVN r22241
2014-09-23 23:35:58 +00:00
Dave Abrahams
dbde275230 [stdlib] Propagate Reflectable docs
230 undocumented public non-operator APIs remain in core

Swift SVN r22236
2014-09-23 23:08:43 +00:00
Dave Abrahams
6bb89ae255 [stdlib] Propagate RangeReplaceableCollectionType docs
240 undocumented public non-operator APIs remain in core

Swift SVN r22235
2014-09-23 22:48:15 +00:00
Dave Abrahams
24fe53ed6c [stdlib] Propagate OutputStream docs
240 undocumented public non-operator APIs remain in core

Note: previous estimates were wrong because my regex was broken.  The
previous commit, for example, had 260 undocumented APIs.

Swift SVN r22234
2014-09-23 22:01:49 +00:00
Dave Abrahams
f5c80b115b [stdlib] Propagate ExtensibleCollectionType docs
184 undocumented public non-operator APIs remain in core

Swift SVN r22231
2014-09-23 21:13:45 +00:00
Dave Abrahams
218d25eb5a [stdlib] Propagate BidirectionalIndexType docs
193 undocumented public non-operator APIs remain in core

Swift SVN r22225
2014-09-23 19:35:31 +00:00
Dave Abrahams
c38e3201b2 [stdlib] Propagate ForwardIndexType docs to models
200 undocumented public APIs remain in core

Swift SVN r22222
2014-09-23 19:20:48 +00:00
Dave Abrahams
7c9ebaa19f [stdlib] Propagate LiteralConvertible docs
219 undocumented public APIs remain in core

Swift SVN r22213
2014-09-23 11:12:39 +00:00
Dave Abrahams
f4a7812065 [stdlib] Propagate SequenceType docs to models
235 undocumented public APIs remain in core

Swift SVN r22210
2014-09-23 10:40:37 +00:00
Dave Abrahams
1dd7272fe9 [stdlib] Propagate CollectionType docs to models
266 undocumented public APIs remain in core

Swift SVN r22206
2014-09-23 08:19:23 +00:00
Doug Gregor
df33350219 Switch string interpolation protocol over to initializer requirements.
With this, we're now using initializer requirements rather than
"convertFromXXX" requirements everywhere, addressing the rest of
rdar://problem/18154091. r22176 eliminated the performance penalty
that prevented this change from sticking earlier.



Swift SVN r22177
2014-09-22 20:17:55 +00:00
Doug Gregor
7764f64cf8 Simplify assertion machinery in the standard library.
This change includes a number of simplifications that allow us to
eliminate the type checker hack that specifically tries
AssertString. Doing so provides a 25% speedup in the
test/stdlib/ArrayNew.swift test (which is type-checker bound).

The specific simplifications here:
  - User-level
  assert/precondition/preconditionalFailure/assertionFailer/fatalError
  always take an autoclosure producing a String, eliminating the need
  for the StaticString/AssertString dance.
  - Standard-library internal _precondition/_sanityCheck/etc. always
  take a StaticString. When we want to improve the diagnostics in the
  standard library, we can provide a separate overload or
  differently-named function.
  - Remove AssertString, AssertStringType, StaticStringType, which are
  no longer used or needed
  - Remove the AssertString hack from the compiler
  - Remove the "BooleanType" overloads of these functions, because
  their usefuless left when we stopped making optional types conform
  to BooleanType (sorry, should have been a separate patch).



Swift SVN r22139
2014-09-19 17:56:50 +00:00
Doug Gregor
82d7daf5fc Revert StringInterpolationConvertible back to class method requirements.
The initializer requirement is causing too much exponential behavior
in the constraint solver. We'll have to address that
first. Re-instating this change is tracked by rdar://problem/18381811.


Swift SVN r22080
2014-09-18 17:10:53 +00:00
Doug Gregor
f1e47a7b18 Switch string interpolation protocol over to initializer requirements.
With this, we're now using initializer requirements rather than
"convertFromXXX" requirements everywhere, addressing the rest of
rdar://problem/18154091.


Swift SVN r22078
2014-09-18 16:13:18 +00:00
Doug Gregor
3ebf5cb3da Switch the string literal protocols over to initializer requirements.
Swift SVN r22076
2014-09-18 15:48:42 +00:00
Dave Abrahams
69075bc61d [stdlib] Kill unintended argument label
Fixes <rdar://problem/18232095> Remove mandatory keyword from generic String init

Swift SVN r21801
2014-09-09 03:50:40 +00:00
Dmitri Hrybenko
4139fe129e stdlib: underscore-prefix private type Character.SmallUTF16
Swift SVN r21640
2014-09-02 14:26:51 +00:00
Dmitri Hrybenko
51a8becf1c stdlib/String: strength-reduce some String methods: prefer StringCore.append
over String.extend

Performance testsuite changes over 2% are as follows.  A lot of tests unrelated
to String have been affected because of measurement noise and because strings
are used in result verification.

                 Ary3     4.8%
          CaptureProp    10.3%
           Dictionary    -4.0%
         EditDistance     2.8%
               Forest    -4.0%
                 Hash     8.6%
        InsertionSort     6.7%
                 Life    -2.3%
               MatMul     2.6%
           NestedLoop     3.9%
        PopFrontArray     2.9%
             PrimeNum     3.6%
                Prims     2.2%
              SmallPT    -2.1%
               TwoSum     4.1%

Swift SVN r21629
2014-09-01 14:30:41 +00:00
Dmitri Hrybenko
985def47c9 stdlib: improve performance of string appending
CaptureProp ,  -21.8%
             HeapSort ,   12.7%
            ImageProc ,  -25.6%
               StrCat ,   92.6%
       StrComplexWalk ,   11.1%
             StrToInt ,   16.6%
  StringInterpolation ,   21.6%

Regression in CaptureProp is due to some interference of the harness.  When the
code is extracted into a separate file, there is no difference.

Regression in ImageProc is caused by unconditional construction of a string for
CheckResults()

rdar://18119872

Swift SVN r21535
2014-08-28 16:48:39 +00:00
Dmitri Hrybenko
4acc8a3e4b stdlib: remove redundant parens
Swift SVN r21529
2014-08-28 14:10:07 +00:00
Roman Levenstein
97014172b7 [sil-combine] String literal concatenation optimization. Constant-fold concatenation of string literals known at compile-time.
Addresses rdar://17033696.

Swift SVN r21526
2014-08-28 11:33:21 +00:00
Dave Abrahams
f3ac09497d Store ASCII string literals as UTF8
Fixes <rdar://problem/16740011> ASCII string literals produce UTF16
Strings

Swift SVN r21419
2014-08-22 19:05:15 +00:00
Dmitri Hrybenko
16604871b3 stdlib: disallow concatenating Characters with "+"
rdar://18026160


Swift SVN r21249
2014-08-18 10:13:36 +00:00
Dave Abrahams
980ccb7788 [stdlib] Fix reserve when extending String
I wish I knew how to code a regression test for this, but sadly I don't.

The only performance differences with magnitude > 7% show up in
-Ounchecked, and most of these look suspiciously like noise due to the
irrelevance of generic string append.  The only one I'd be remotely
concerned about is StrToInt, but it doesn't make any sense that it
should have gotten slower, so I think that's noise too.

Ackermann: -14.3%
Fibonacci: 33.3%
ImageProc: 9.0%
Phonebook: -7.1%
QuickSort: 15.6%
StrToInt: -14.3%

Swift SVN r21236
2014-08-15 16:44:10 +00:00
Dmitri Hrybenko
84abad0be4 stdlib: clarify a trap error message
Swift SVN r21205
2014-08-14 17:36:27 +00:00
Doug Gregor
7a80e1249e Minor standard library cleanups. NFC
Swift SVN r21203
2014-08-14 17:27:43 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Dmitri Hrybenko
2f80b28c5f stdlib: remove a bogus implementation of an unavailable function
Swift SVN r21193
2014-08-14 11:33:31 +00:00
Nadav Rotem
4cf6181785 Replace @semantics("readonly") with @effects(readonly).
Swift SVN r21088
2014-08-07 07:22:18 +00:00