Skip to content

Commit

Permalink
move creation of new scanner into scanner class itself
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlippert committed Jan 7, 2025
1 parent 027cbf9 commit c434b8a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5906,4 +5906,18 @@ protected void growCommentInfoArrays(int length, int newLength) {
System.arraycopy(this.commentTagStarts, 0, this.commentTagStarts = new int[newLength], 0, length);
}

@Override
public Scanner clone() {
return new Scanner(
this.tokenizeComments,
this.tokenizeWhiteSpace,
this.checkNonExternalizedStringLiterals,
this.sourceLevel,
this.complianceLevel,
this.taskTags,
this.taskPriorities,
this.isTaskCaseSensitive,
this.previewEnabled);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,7 @@ void internalSetEscapedValue(String value) {
*/
public char charValue() {
// create a new local scanner to allow concurrent use
Scanner scanner = new Scanner(
this.ast.scanner.tokenizeComments,
this.ast.scanner.tokenizeWhiteSpace,
this.ast.scanner.checkNonExternalizedStringLiterals,
this.ast.scanner.sourceLevel,
this.ast.scanner.complianceLevel,
this.ast.scanner.taskTags,
this.ast.scanner.taskPriorities,
this.ast.scanner.isTaskCaseSensitive,
this.ast.scanner.previewEnabled);
Scanner scanner = this.ast.scanner.clone();

char[] source = this.escapedValue.toCharArray();
scanner.setSource(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,7 @@ public String getLiteralValue() {
}

// create a new local scanner to allow concurrent use
Scanner scanner = new Scanner(
this.ast.scanner.tokenizeComments,
this.ast.scanner.tokenizeWhiteSpace,
this.ast.scanner.checkNonExternalizedStringLiterals,
this.ast.scanner.sourceLevel,
this.ast.scanner.complianceLevel,
this.ast.scanner.taskTags,
this.ast.scanner.taskPriorities,
this.ast.scanner.isTaskCaseSensitive,
this.ast.scanner.previewEnabled);
Scanner scanner = this.ast.scanner.clone();

char[] source = s.toCharArray();
scanner.setSource(source);
Expand Down

0 comments on commit c434b8a

Please sign in to comment.