Commit Graph

9 Commits

Author SHA1 Message Date
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Karoy Lorentey
50bd37b49a [stdlib] Eliminate _HasherCore protocol 2018-11-07 13:45:56 +00:00
Karoy Lorentey
3ae170c1c1 [stdlib] Remove SipHash from ABI-visible names
Also, eliminate the (unused) SipHash24 implementation and nest most of Hasher’s internals under Hasher itself.
2018-11-01 00:45:40 +00:00
Karoy Lorentey
68b9b08cdd [stdlib] Add 256 bits of extra state to Hasher 2018-11-01 00:43:53 +00:00
Karoy Lorentey
6d81663716 [stdlib] Make Hashable._rawHashValue(seed:) safer and more convenient
- Don’t expose the raw execution seed to _rawHashValue.
- Change the type of _rawHashValue’s seed from (UInt64,UInt64) to a single Int. Working with a pair of UInt64s is unwieldy, and overkill in practice. Int as a seed also integrates nicely with Int as a hash value.
- Remove _HasherCore._generateSeed(). Instead, simply call finalize() on a copy of the hasher to get a seed suitable for _rawHashValue.
- Update Set and Dictionary to store a single Int as the seed value.

Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name “rawSeed” to refer to an actual 128-bit seed value.
2018-09-24 13:30:05 +01:00
Jordan Rose
55eaa7ffcf [stdlib] Add some missing '@usableFromInline's
Caught by the rule I'm about to add in the next commit: a fixed-layout
struct must only contain public/@usableFromInline members.
2018-09-17 17:18:30 -07:00
Karoy Lorentey
3a162d225a [stdlib] Hashable, Hasher: Add non-public top-level hashing interface
The new _rawHashValue(seed:) requirement allows stdlib types to specialize their hashing when they’re hashed on their own (i.e., not as a component of some composite type).

This makes it possible to get rid of discriminator/terminator values and to eliminate most of Hasher’s resiliency overhead, leading to a measurable speedup, especially for tiny keys.
2018-04-30 15:16:47 +01:00
Karoy Lorentey
97ec2967e0 [SE-0206][stdlib] Hasher, SipHash: Make non-public declarations internal
Newly internal declarations include Hasher._seed and the integer overloads of Hasher._combine(_:), as well as _SipHash13 and _SipHash24.

Unify the interfaces of these SipHash testing structs with Hasher. Update SipHash test to cover Hasher, too.

Add @usableFromInline to all newly internal stuff. In addition to its normal use, it also enables white box testing; compile tests that need to use these declarations with -disable-access-control.
2018-04-24 17:42:42 +01:00
Karoy Lorentey
7e66a38af8 [stdlib] De-gyb SipHash; implement full Hasher API 2018-04-18 17:33:24 +01:00