8000 Go back to memcmp() for companing OIDs, for performance reasons · Uncommon/Xit@738ca60 · GitHub
[go: up one dir, main page]

Skip to content

Commit 738ca60

Browse files
committed
Go back to memcmp() for companing OIDs, for performance reasons
1 parent 9b05de7 commit 738ca60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Xit/Repository/OID.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,17 @@ extension GitOID: CustomStringConvertible
170170
public var description: String { sha }
171171
}
172172

173+
let oidSize = 20
174+
173175
public func == (left: GitOID, right: GitOID) -> Bool
174176
{
175177
left.withUnsafeOID {
176178
(leftOID) in
177179
right.withUnsafeOID {
178180
(rightOID) in
179-
git_oid_equal(leftOID, rightOID) != 0
181+
// git_oid_equal() is slowed down by the use of git_oid_size(), which isn't
182+
// even needed with SHA256 support turned off
183+
memcmp(leftOID, rightOID, oidSize) == 0
180184
}
181185
}
182186
}

0 commit comments

Comments
 (0)
0