mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Patch.sum/difference are not allowed to throw.
This commit is contained in:
parent
3f81b9d8b9
commit
8cf0ef097c
@ -73,20 +73,20 @@ extension Patch {
|
||||
|
||||
extension Patch {
|
||||
/// Returns a function which computes the size of a `patch` as the sum of the sizes of its terms, as computed by `size`.
|
||||
public static func sum(@noescape size: A throws -> Int)(_ patch: Patch) rethrows -> Int {
|
||||
public static func sum(@noescape size: A -> Int)(_ patch: Patch) -> Int {
|
||||
switch patch {
|
||||
case let .Replace(a, b):
|
||||
return try size(a) + size(b)
|
||||
return size(a) + size(b)
|
||||
case let .Insert(b):
|
||||
return try size(b)
|
||||
return size(b)
|
||||
case let .Delete(a):
|
||||
return try size(a)
|
||||
return size(a)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a function which computes the size of a `patch` as the absolute difference of the sizes of its terms, as computed by `size`.
|
||||
public static func difference(@noescape size: A throws -> Int)(_ patch: Patch) rethrows -> Int {
|
||||
return try abs((patch.state.before.map(size) ?? 0) - (patch.state.after.map(size) ?? 0))
|
||||
public static func difference(@noescape size: A -> Int)(_ patch: Patch) -> Int {
|
||||
return abs((patch.state.before.map(size) ?? 0) - (patch.state.after.map(size) ?? 0))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user