mirror of
https://github.com/github/semantic.git
synced 2024-11-29 11:02:26 +03:00
Patches have a cost.
This charges `Replace` patches at a higher cost than `Insert`/`Delete` patches to avoid spurious replacements.
This commit is contained in:
parent
bcc3da35f9
commit
4fdbcf948f
@ -16,6 +16,17 @@ public enum Patch<A>: CustomDebugStringConvertible {
|
||||
}
|
||||
|
||||
|
||||
/// The cost of a patch to the diff.
|
||||
public var cost: Int {
|
||||
switch self {
|
||||
case .Replace:
|
||||
return 2
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
|
||||
public var debugDescription: String {
|
||||
|
Loading…
Reference in New Issue
Block a user