You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/08/14 00:09:25 UTC
[groovy] branch GROOVY_4_0_X updated: Trivial refactoring: extract variable
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new 3ff5e600de Trivial refactoring: extract variable
3ff5e600de is described below
commit 3ff5e600ded0428b56e85f3bb5829f9880a3b78d
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Aug 14 08:09:03 2022 +0800
Trivial refactoring: extract variable
---
src/main/java/org/codehaus/groovy/control/SourceUnit.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/control/SourceUnit.java b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
index f62f857709..b5ac3d492b 100644
--- a/src/main/java/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
@@ -282,11 +282,11 @@ public class SourceUnit extends ProcessingUnit {
if (column > 40) {
int start = column - 30 - 1;
- int end = (column + 10 > text.length() ? text.length() : column + 10 - 1);
- if (start >= text.length() || end < start)
+ int length = text.length();
+ int end = (column + 10 > length ? length : column + 10 - 1);
+ if (start >= length || end < start)
return null; // can happen with CR only files GROOVY-10676
- sample = " " + text.substring(start, end) + Utilities.eol() + " " +
- marker.substring(start);
+ sample = " " + text.substring(start, end) + Utilities.eol() + " " + marker.substring(start);
} else {
sample = " " + text + Utilities.eol() + " " + marker;
}