Skip to content

Commit 0d1a355

Browse files
committed
Some more performance tweaks for GroovyParserVisitor
1 parent f0329a1 commit 0d1a355

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,7 @@ private J.EnumValue visitEnumField(FieldNode field) {
448448
List<J.Annotation> annotations = visitAndGetAnnotations(field, this);
449449

450450
Space namePrefix = whitespace();
451-
String enumName = field.getName();
452-
skip(enumName);
451+
String enumName = skip(field.getName());
453452

454453
J.Identifier name = new J.Identifier(randomId(), namePrefix, Markers.EMPTY, emptyList(), enumName, typeMapping.type(field.getType()), typeMapping.variableType(field));
455454

@@ -462,7 +461,7 @@ private J.EnumValue visitEnumField(FieldNode field) {
462461
int start = cursor;
463462
int argCount = 0;
464463
int depth = 0;
465-
whitespace();
464+
cursor = indexOfNextNonWhitespace(cursor, source);
466465
while (!(source.charAt(cursor) == ')' && depth == 0)) {
467466
Delimiter delimiter = getDelimiter(null, cursor);
468467
if (delimiter != null) {
@@ -479,15 +478,15 @@ private J.EnumValue visitEnumField(FieldNode field) {
479478
} else {
480479
name();
481480
}
482-
whitespace();
481+
cursor = indexOfNextNonWhitespace(cursor, source);
483482
skip(",");
484-
whitespace();
483+
cursor = indexOfNextNonWhitespace(cursor, source);
485484
if (source.charAt(cursor) == '(') {
486485
depth++;
487-
skip("(");
486+
cursor++;
488487
} else if (depth > 0 && source.charAt(cursor) == ')') {
489488
depth--;
490-
skip(")");
489+
cursor++;
491490
}
492491
argCount++;
493492
}
@@ -2612,7 +2611,7 @@ private Space whitespace() {
26122611
/**
26132612
* Move the cursor after the token.
26142613
*/
2615-
private String skip(@Nullable String token) {
2614+
private @Nullable String skip(@Nullable String token) {
26162615
if (token == null) {
26172616
//noinspection ConstantConditions
26182617
return null;

0 commit comments

Comments
 (0)