Commit Graph

269 Commits

Author SHA1 Message Date
Karoy Lorentey
7e66a38af8 [stdlib] De-gyb SipHash; implement full Hasher API 2018-04-18 17:33:24 +01:00
Karoy Lorentey
ccdc218cbd [stdlib] _Hasher: append => combine 2018-04-18 14:18:44 +01:00
Nate Cook
a63f5bf788 [stdlib] Revise masking shift and unsafe operation docs 2018-04-11 11:34:59 -05:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Max Moiseev
cee7efca65 Un-implement dividingFullWidth for 64bit types on 32bit platforms
The implementation uses DoubleWidth<T> that needs to be removed due to
library binary size issues. Even extracting the single DoubleWidth
method that's used in it would likely result in having to copy a
large portion of the rest of DoubleWidth implementation along with it,
this defeating the purpose.

This change restores the behavior of dividingFullWidth as it was shipped
with Swift 4.1, therefore it's not a breaking change.
2018-03-23 16:15:18 -07:00
Stephen Canon
8e11af4012 Make the naming of underlying builtin for FP + Vector match Integer. (#15430)
* Make the underlying builtins for FP + Vector match Integer.

For stdlib integer types, these are named `_value` and `init(_ _value: Builtin.xxx)`. This patch adopts the same scheme for stdlib floating point and SDK overlay vector types, and removes a legacy init for integers that was only needed to support them. There should be no changes visible outside of the stdlib, and no functional change within the stdlib; the naming of some implementation details is simply more uniform now.
2018-03-22 16:43:20 -04:00
Max Moiseev
d50f60cc73 Merge pull request #15144 from rockbruno/overflow-assignment-2
[stdlib][SR-4818] Add overflow assignment operators
2018-03-19 16:05:56 -07:00
Jordan Rose
74a4adc54c [stdlib] Remove ignored platform-agnostic '@available' from extensions
It looks like we exposed a bunch of Metal APIs to Swift 3 that we
didn't mean to; at this point it would be a source-breaking change to
hide them. Oops.
2018-03-14 16:37:40 -07:00
bruno-rocha-movile
3b074205ad [stdlib] Revert overflow operators implementation change and improve their documentation 2018-03-10 17:25:16 -03:00
bruno-rocha-movile
9750689210 [stdlib][SR-4818] Add overflow assignment operators 2018-03-10 13:55:45 -03:00
Karoy Lorentey
54b857ed0b [stdlib] Hashable: Add support for resilient hashing
Introduce _Hasher, representing an opaque hash compression function.

Add the method _hash(into:) as a Hashable requirement, decoupling the choice of hash function from Hashable's implementation. The default implementation of _hash(into:) has a default implementation that simply feeds hashValue to the hasher.

Add _hash(into:) implementations for the default integer types. Note that Int.hashValue does not return self anymore.

Add struct _LegacyHasher, emulating Swift 4.1 hashes in the new interface.
2018-03-09 14:34:57 +00:00
Xiaodi Wu
1fe344b51f [stdlib] Match actual method names in an internal comment 2018-03-04 19:55:37 -06:00
Nate Cook
642cbbad7c [stdlib] Documentation revisions and expansions
- Adding docs for unbounded ranges
- Filling in missing docs for range-expression subscripts
- Equality operators for arrays
- Fix issues with range discussions
- Fill in missing integer docs
2018-02-19 11:49:58 -06:00
Xiaodi Wu
26dac8f5e0 Address reviewer comments for consolidated integer-to-string conversion 2018-02-06 21:40:49 -06:00
Xiaodi Wu
76e23368ad Consolidate integer-to-string implementations 2018-02-03 19:17:48 -06:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Xiaodi Wu
21d59c415d Address reviewer feedback 2018-01-31 15:09:15 -06:00
Xiaodi Wu
78875d934c Update and fill in documentation for DoubleWidth and integer protocols 2018-01-30 20:52:24 -06:00
Xiaodi Wu
4b9ff41303 Address reviewer comments 2018-01-30 18:55:19 -06:00
Xiaodi Wu
cc0e64dec4 Implement efficient DoubleWidth division and fix division-related bugs 2018-01-28 14:01:06 -06:00
Xiaodi Wu
7e03829aab Improve _binaryLogarithm implementation and add tests 2018-01-18 16:45:41 -06:00
Max Moiseev
c8b12ee282 [stdlib] Adding derived equality/comparison operators to concrete integer types 2018-01-08 17:19:12 -08:00
Xiaodi Wu
d965a13c44 Implement generic conversions to floating point 2018-01-06 19:03:23 -06:00
Nate Cook
0782b482b3 [stdlib] Documentation improvements
- Revise Equatable and Hashable for synthesized requirements
- Complete Strideable and stride(from:...:by:) documentation
- Revise DoubleWidth type docs
- Add complexity notes for Set.index(of:) and .contains(_:)
- Fix typos in Set.formUnion docs
- Add missing axioms for SetAlgebra (SR-6319)
- Improve guidance for description and debugDescription
- Add note about the result of passing duplicate keys to
  Dictionary(uniqueKeysWithValues:)
- Fix typo in BinaryInteger docs
- Update Substring docs with better conversion example
- Improve docs for withMemoryRebound and isKnownUniquelyReferenced
- Add missing docs not propagated from protocols
2018-01-05 17:06:44 -06:00
Xiaodi Wu
cf179dada0 Fix a bug with unsigned integers in FixedWidthInteger._convert(from:) 2018-01-01 14:56:17 -06:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Max Moiseev
8dbaa2a752 Revert "[stdlib] Temporarily exclude DoubleWidth from the standard library" 2017-12-05 15:37:07 -08:00
Max Moiseev
156e6eb848 Exclude DoubleWidth due to the binary size concerns
<rdar://problem/32726173>
2017-12-01 14:29:53 -08:00
Ben Cohen
c4f0b5fe94 [stdlib] Adopt conditional conformance for Indices, Slice, ReversedCollection (#12913)
* Refactor Indices and Slice to use conditional conformance

* Replace ReversedRandomAccessCollection with a conditional extension

* Refactor some types into struct+extensions

* Revise Slice documentation

* Fix test cases for adoption of conditional conformances.

* [RangeReplaceableCollection] Eliminate unnecessary slicing subscript operator.

* Add -enable-experimental-conditional-conformances to test.

* Gruesome workaround for crasher in MutableSlice tests
2017-11-30 09:10:22 -08:00
Philip Ridgeway
6926fd3412 Removes a superfluous "the" in a documentation comment. 2017-11-20 11:04:04 -08:00
Max Moiseev
93afb243ca Merge pull request #11917 from natecook1000/nc-uint-advance
[stdlib] Fix strideable methods for large unsigned values
2017-10-11 10:08:29 -07:00
Nate Cook
37b4083ac7 [stdlib] Try inlining integer stride methods 2017-10-10 13:00:36 -05:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Doug Gregor
31ad22df45 Make Numeric.Magnitude conform to Numeric 2017-10-01 15:08:22 -07:00
Xiaodi Wu
d88836bbf8 [stdlib] Fix strideable methods for large unsigned values
Int is still an insufficient stride type for binary integers,
but this improves the situation for values at the extremes of the
concrete integer types.
2017-09-29 22:58:11 -05:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
swift-ci
79a3f9c415 Merge pull request #11670 from natecook1000/nc-rev-77-2 2017-09-19 10:15:59 -07:00
Nate Cook
4a1b74c266 [stdlib] Additional revisions
- Incorporate feedback from @xwu
- Add parameters for `dump`
- Duplicate some missing integer comments
2017-09-12 11:21:54 -05:00
Xiaodi Wu
d661204d7e Remove operators from Integers.swift.gyb 2017-09-02 12:05:18 -05:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Xiaodi Wu
2d92c3969e Update documentation for init(truncatingIfNeeded:) 2017-08-27 14:43:20 -05:00
Xiaodi Wu
7e11f1822c Implement fixed-width integer conversions from binary floating point
Make internal stdlib function public because it is called from stdlib tests

Add some first-thought optimizations
2017-08-22 19:52:33 -05:00
Roman Levenstein
317e681a5b Mark more functions as @_inlineable to improve the performance of the stdlib in resilient mode 2017-08-21 16:16:07 -07:00
Roman Levenstein
03dba709f3 [stdlib-code-size] Do not produce useless partial specializations for the shift operations on integers
This reduces the stdlib binary size by 200KB.
2017-08-07 17:12:26 -07:00
Nate Cook
1698fd388b [stdlib] Manually propagate integer documentation 2017-08-01 15:17:20 -05:00
Nate Cook
781f6326bd [stdlib] Various documentation revisions and fixes
- Revisions to unsafeDowncast and withVaList
- Fix the Int64/UInt64 discussion
- Buffer pointer revisions
- Fix Optional example to use new integer methods
- Revise and correct some UnsafeRawBufferPointer docs
- Fix symmetricDifference examples
- Fix wording in FloatingPoint.nextDown
- Update ImplicitlyUnwrappedOptional
- Clarify elementsEqual
- Minor integer doc fixes
- Comment for _AppendKeyPath
- Clarification re collection indices
- Revise RangeExpression.relative(to:)
- Codable revisions
2017-07-31 10:56:53 -05:00
Maxim Moiseev
52259b714b Merge pull request #11193 from xwu/lossless-integers
[stdlib] Conform fixed-width integer types to LosslessStringConvertible
2017-07-28 20:10:07 -07:00
Max Moiseev
5563ed1999 [stdlib] Remove reintroduced extendingOrtruncating call 2017-07-28 12:16:56 -07:00