From 8e1aa0191e519ccfbca1e300bb6c75d35d6efede Mon Sep 17 00:00:00 2001 From: Luminous-Coder <84374077+Luminous-Coder@users.noreply.github.com> Date: Sun, 21 Aug 2022 15:09:13 +0800 Subject: [PATCH] Improve readability according to the comment --- src/main/java/chaos/unity/nenggao/Span.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/chaos/unity/nenggao/Span.java b/src/main/java/chaos/unity/nenggao/Span.java index 8f8fc19..9ad90db 100644 --- a/src/main/java/chaos/unity/nenggao/Span.java +++ b/src/main/java/chaos/unity/nenggao/Span.java @@ -25,9 +25,7 @@ public boolean isIn(int line) { * @return offset of two position. */ public int offset() { - if (startPosition.pos > endPosition.pos) { - return -1; - } else if (startPosition.line != endPosition.line) { + if (startPosition.line != endPosition.line || startPosition.pos > endPosition.pos) { return -1; } return endPosition.pos - startPosition.pos;