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 01:32:15 UTC

[groovy] branch master updated: Trivial refactoring: extract variable

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 0fe5c80d3b Trivial refactoring: extract variable
0fe5c80d3b is described below

commit 0fe5c80d3bebe0e00acf4190fa755a45c7a4b80c
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;
                 }