Commit Graph

431 Commits

Author SHA1 Message Date
Karoy Lorentey
75a376d319 [stdlib] Use Int._binaryLogarithm() to round up to nearest power of 2 2018-01-25 15:48:34 +00:00
Karoy Lorentey
92a2f9cb8f Merge pull request #14027 from lorentey/rdar/36619317
[stdlib] Set, Dictionary: Take the max load factor into account in `.init(minimumCapacity:)`
2018-01-24 11:31:17 +00:00
Karoy Lorentey
de2add8047 [stdlib] Set, Dictionary terminology: Distinguish capacity from bucket count.
"Capacity" in the public Set/Dictionary API means the maximum number of items that a collection instance may hold without reallocation. In implementation details, the same word was also used for the capacity of the underlying storage buffer, which is usually higher due to the maximum load factor.

Having the same name for two different values has led to bugs where the logical/effective capacity is passed directly to a function expecting the raw storage capacity, or vice versa. This change updates internal names to clearly distinguish between the two senses, introducing "bucketCount" as the name for the storage buffer capacity, and reserving "capacity" for the maximum logical item count.
2018-01-23 17:22:31 +00:00
Slava Pestov
834a121b10 AST: @objc_non_lazy_realization should be underscored and UserInaccessible 2018-01-21 01:31:44 -08:00
Karoy Lorentey
3b1bae9ca2 [stdlib] Set, Dictionary: Take the max load factor into account in .init(minimumCapacity:)
rdar://problem/36619317
2018-01-19 17:38:16 +00:00
Max Moiseev
5650f80937 [stdlib] Annotate types with @_fixed_layout
This will allows us to build the standard library in resilient mode by
default, hopefully, without performance regression.

<rdar://problem/36362648>
2018-01-09 14:46:30 -08: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
Karoy Lorentey
9fef06e59c Merge pull request #12752 from hamishknight/dictionary-subscript-addressor
[stdlib] Use addressor for Dictionary's subscript(_:default:)
2017-12-04 15:04:29 +01:00
Hamish
7876391f47 [stdlib] Call nativePointerToValue(at:) from nativePointerToValue(forKey:insertingDefault:) 2017-12-03 17:28:45 +00:00
Ben Cohen
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08:00
Hamish
4b3f0374c8 [stdlib] Don't check for native when known native in ensureNativeBuffer() 2017-11-28 19:34:01 +00:00
Nate Cook
6c66cf3e61 [stdlib] Make stdlib index types Hashable
This adds Hashable conformance for the String, Dictionary,
and Set's index types.
2017-11-28 13:29:55 -06:00
Huon Wilson
39e0a951b8 [stdlib] Make Optional, Array and Dictionary conditionally Equatable. 2017-11-27 21:09:49 -08:00
Hamish
12416f94bb [stdlib] Don't use autoclosure on pointerToValue(forKey:insertingDefault:) methods
Previously we used @autoclosure on the _VariantDictionaryBuffer methods and forwarded closures directly.
However, this relied on an unintentional type-checker inconsistency, tracked by SR-5719.
2017-11-21 17:51:00 +00:00
Hamish
76ea3a2ca4 [stdlib] Fix uniqueness check in nativePointerToValue(forKey:insertingDefault:)
The reasoning for this change is detailed in PR-13000.
2017-11-19 22:37:05 +00:00
Hamish
79d8209ffa [stdlib] Use addressor for Dictionary's subscript(_:default:) 2017-11-19 15:45:27 +00:00
swift-ci
53ddcb5079 Merge pull request #13000 from gottesmm/pr-6a0399e1ebd7ccad1979a2af165d0b09595fb2cb 2017-11-18 20:55:27 -08:00
Michael Gottesman
89cefe0a70 [stdlib] Use a different access pattern to check uniqueness to work around more conservative SILGen codegen.
Using && here causes us to go down a SILGen path that guarantees that self will
be evaluated over the entire && expression instead of just the LHS. This cause
the uniqueness check to always return false at -Onone. At -O, the optimizer is
smart enough to remove this issue.

rdar://33358110
2017-11-18 20:16:28 -07:00
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Greg Parker
1e894cd80b [runtime] Clean up symbols in error machinery. (#12853)
* [runtime] Clean up symbols in error machinery.

* [runtime] Clean up symbols in Foundation overlay.

* [runtime] Clean up symbols in collections and hashing.

* [runtime] Remove symbol controls from the Linux definition of swift_allocError.

* [tests] Add more stub functions for tests that link directly to the runtime.
2017-11-15 22:20:11 -08:00
Greg Parker
e8475cc130 Revert "Use conditional conformances to implement Equatable for Optional, Array and Dictionary" 2017-11-15 14:17:22 -08:00
Huon Wilson
8524379352 [stdlib] Make Optional, Array and Dictionary conditionally Equatable. 2017-11-14 16:23:20 -08:00
Roman Levenstein
111499d2bf Merge pull request #12256 from swiftix/sil-serialize-all-improvments
Remove the -sil-serialize-all option
2017-10-05 22:03:41 -07:00
Karoy Lorentey
7dabd3ee1a Merge pull request #12249 from lorentey/rdar/34672149
[stdlib] Dictionary.Keys, .Values: Implement Custom[Debug]StringConvertible
2017-10-05 11:31:14 +01:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00
Karoy Lorentey
4ff5a41061 [stdlib] Dictionary.Keys, .Values: Implement Custom[Debug]StringConvertible.
This prevents a crash while printing these collections.

Resolves:
https://bugs.swift.org/browse/SR-6003
rdar://problem/34672149
2017-10-04 12:40:00 +01:00
Karoy Lorentey
e4ef5203d2 [stdlib] Extract Array._makeDescription into standalone function
This enables its use for collection types unrelated to Arrays.
Use the new function to replace Set’s implementation of
Custom[Debug]StringConvertible.
2017-10-04 12:40:00 +01:00
Slava Pestov
0fad13eeba SIL: Remove special meaning for @_semantics("stdlib_binary_only")
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-03 13:48:22 -07:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Max Moiseev
ef6b5c4795 Add missing @_inlineable attributes and deinits 2017-09-29 11:26:56 -07: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
Maxim Moiseev
6c7d93491f Merge pull request #11627 from moiseev/swift-2-artifacts
[stdlib] Remove the Grand Renaming artifacts of Swift 3 era
2017-09-05 11:41:18 -07: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
Maxim Moiseev
ee5fb33656 [stdlib] Remove the Grand Renaming artifacts of Swift 3 era 2017-08-28 15:54:11 -07: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
Rintaro Ishizaki
c36cb57054 [stdlib] Fix warnings in non-ObjC platforms. (#11200) 2017-07-26 22:42:55 +09:00
swift-ci
4d5dfdd42c Merge pull request #10966 from rintaro/stdlib-hashedcollection-switchcase 2017-07-24 00:51:08 -07:00
Dave Abrahams
c497969987 [stdlib] Swift4 Modernizations Compatible with Swift 3.2 2017-07-14 17:54:33 -07:00
Rintaro Ishizaki
d2eab3c342 [stdlib] Use #if guarded switch case
_Cocoa{Set,Dictionary}{Buffer,Index,Iterator} can be completely
eliminated from non-ObjC runtime environments.
2017-07-14 18:14:34 +09:00
Dave Abrahams
1da820da74 Merge pull request #10275 from natecook1000/nc-dict-grouping
[stdlib] Move Dictionary(grouping:by) down a level
2017-06-19 16:56:04 -07:00
Nate Cook
695a7f975e [stdlib] Move Dictionary(grouping:by) down a level 2017-06-16 00:51:38 -05:00
Nate Cook
825e9d077d [stdlib] More documentation revisions / consistency fixes. 2017-06-13 14:08:00 -05:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Nate Cook
0a7780c213 [stdlib] Various minor documentation revisions 2017-06-12 16:20:11 -05:00
Nate Cook
b2e9d74d5a [stdlib] Add dictionary overloads for merge/merging methods
This resolves the issue where a dictionary can’t be passed to
the Dictionary.merge and .merging methods. rdar://problem/32352586
2017-06-05 15:54:11 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Nate Cook
7fa74f590d [stdlib] Documentation revisions for string + ranges
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
2017-05-13 10:06:05 -05:00
Nate Cook
822fec7b2b [stdlib] Make new Dict filter closure type match sequence 2017-05-10 11:24:37 -05:00
Nate Cook
44b12db536 [stdlib] Maintain old keys and values types in Swift 3 mode 2017-05-10 10:45:05 -05:00