Merge "Reduce compares in Edit.getType"

This commit is contained in:
Chris Aniszczyk 2010-09-06 22:33:09 -04:00 committed by Code Review
commit 18aadc826d
1 changed files with 12 additions and 7 deletions

View File

@ -121,13 +121,18 @@ public Edit(final int as, final int ae, final int bs, final int be) {
/** @return the type of this region */
public final Type getType() {
if (beginA == endA && beginB < endB)
return Type.INSERT;
if (beginA < endA && beginB == endB)
return Type.DELETE;
if (beginA == endA && beginB == endB)
return Type.EMPTY;
return Type.REPLACE;
if (beginA < endA) {
if (beginB < endB)
return Type.REPLACE;
else /* if (beginB == endB) */
return Type.DELETE;
} else /* if (beginA == endA) */{
if (beginB < endB)
return Type.INSERT;
else /* if (beginB == endB) */
return Type.EMPTY;
}
}
/** @return true if the edit is empty (lengths of both a and b is zero). */