mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Migrate to the new method for Hashable conformance
This commit is contained in:
parent
e16d5c6baa
commit
cf24dc9ed6
@ -57,19 +57,9 @@ extension OID: CustomStringConvertible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension OID: Hashable {
|
extension OID: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
let bytes = [
|
withUnsafeBytes(of: oid.id) {
|
||||||
self.oid.id.0,
|
hasher.combine(bytes: $0)
|
||||||
self.oid.id.1,
|
|
||||||
self.oid.id.2,
|
|
||||||
self.oid.id.3,
|
|
||||||
self.oid.id.4,
|
|
||||||
self.oid.id.5,
|
|
||||||
self.oid.id.6,
|
|
||||||
self.oid.id.7,
|
|
||||||
]
|
|
||||||
return bytes.reduce(0) { (hash, byte) in
|
|
||||||
return Int(hash << 8) | Int(byte)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,8 +70,10 @@ public struct Signature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Signature: Hashable {
|
extension Signature: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return name.hashValue ^ email.hashValue ^ time.timeIntervalSince1970.hashValue
|
hasher.combine(name)
|
||||||
|
hasher.combine(email)
|
||||||
|
hasher.combine(time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +121,8 @@ public struct Commit: ObjectType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Commit: Hashable {
|
extension Commit: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return self.oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +177,10 @@ public struct Tree: ObjectType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Tree.Entry: Hashable {
|
extension Tree.Entry: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return Int(attributes) ^ object.hashValue ^ name.hashValue
|
hasher.combine(attributes)
|
||||||
|
hasher.combine(object)
|
||||||
|
hasher.combine(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +197,8 @@ public func == (lhs: Tree.Entry, rhs: Tree.Entry) -> Bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Tree: Hashable {
|
extension Tree: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,8 +222,8 @@ public struct Blob: ObjectType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Blob: Hashable {
|
extension Blob: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +258,7 @@ public struct Tag: ObjectType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Tag: Hashable {
|
extension Tag: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,8 +72,8 @@ public enum Pointer: PointerType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Pointer: Hashable {
|
extension Pointer: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public struct PointerTo<T: ObjectType>: PointerType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension PointerTo: Hashable {
|
extension PointerTo: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return oid.hashValue
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,8 +57,9 @@ public struct Reference: ReferenceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Reference: Hashable {
|
extension Reference: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return longName.hashValue ^ oid.hashValue
|
hasher.combine(longName)
|
||||||
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +123,9 @@ public struct Branch: ReferenceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Branch: Hashable {
|
extension Branch: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return longName.hashValue ^ oid.hashValue
|
hasher.combine(longName)
|
||||||
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +196,8 @@ public enum TagReference: ReferenceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension TagReference: Hashable {
|
extension TagReference: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return longName.hashValue ^ oid.hashValue
|
hasher.combine(longName)
|
||||||
|
hasher.combine(oid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,9 @@ public struct Remote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Remote: Hashable {
|
extension Remote: Hashable {
|
||||||
public var hashValue: Int {
|
public func hash(into hasher: inout Hasher) {
|
||||||
return name.hashValue ^ URL.hashValue
|
hasher.combine(name)
|
||||||
|
hasher.combine(URL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user