Skip to content

Commit f0329a1

Browse files
committed
Small performance improvement for Groovy parser
1 parent 6176138 commit f0329a1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,9 +2603,10 @@ private int positionOfNext(String untilDelim) {
26032603
* The cursor will be moved before first non-whitespace character.
26042604
*/
26052605
private Space whitespace() {
2606-
String prefix = source.substring(cursor, indexOfNextNonWhitespace(cursor, source));
2607-
cursor += prefix.length();
2608-
return format(prefix);
2606+
int endIndex = indexOfNextNonWhitespace(cursor, source);
2607+
Space space = format(source, cursor, endIndex);
2608+
cursor = endIndex;
2609+
return space;
26092610
}
26102611

26112612
/**

0 commit comments

Comments
 (0)