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 {
|
||||
public var hashValue: Int {
|
||||
let bytes = [
|
||||
self.oid.id.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)
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
withUnsafeBytes(of: oid.id) {
|
||||
hasher.combine(bytes: $0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,8 +70,10 @@ public struct Signature {
|
||||
}
|
||||
|
||||
extension Signature: Hashable {
|
||||
public var hashValue: Int {
|
||||
return name.hashValue ^ email.hashValue ^ time.timeIntervalSince1970.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(name)
|
||||
hasher.combine(email)
|
||||
hasher.combine(time)
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,8 +121,8 @@ public struct Commit: ObjectType {
|
||||
}
|
||||
|
||||
extension Commit: Hashable {
|
||||
public var hashValue: Int {
|
||||
return self.oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,8 +177,10 @@ public struct Tree: ObjectType {
|
||||
}
|
||||
|
||||
extension Tree.Entry: Hashable {
|
||||
public var hashValue: Int {
|
||||
return Int(attributes) ^ object.hashValue ^ name.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
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 {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,8 +222,8 @@ public struct Blob: ObjectType {
|
||||
}
|
||||
|
||||
extension Blob: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +258,7 @@ public struct Tag: ObjectType {
|
||||
}
|
||||
|
||||
extension Tag: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ public enum Pointer: PointerType {
|
||||
}
|
||||
|
||||
extension Pointer: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public struct PointerTo<T: ObjectType>: PointerType {
|
||||
}
|
||||
|
||||
extension PointerTo: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,8 +57,9 @@ public struct Reference: ReferenceType {
|
||||
}
|
||||
|
||||
extension Reference: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(longName)
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,8 +123,9 @@ public struct Branch: ReferenceType {
|
||||
}
|
||||
|
||||
extension Branch: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(longName)
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +196,8 @@ public enum TagReference: ReferenceType {
|
||||
}
|
||||
|
||||
extension TagReference: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(longName)
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,8 +26,9 @@ public struct Remote {
|
||||
}
|
||||
|
||||
extension Remote: Hashable {
|
||||
public var hashValue: Int {
|
||||
return name.hashValue ^ URL.hashValue
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(name)
|
||||
hasher.combine(URL)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user