File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
rewrite-json/src/main/java/org/openrewrite/json/internal
rewrite-toml/src/main/java/org/openrewrite/toml/internal
rewrite-xml/src/main/java/org/openrewrite/xml/internal Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -275,9 +275,11 @@ private Space prefix(Token token) {
275275 }
276276
277277 public int advanceCursor (int newCodePointIndex ) {
278- for (; codePointCursor < newCodePointIndex ; codePointCursor ++ ) {
279- cursor = source . offsetByCodePoints ( cursor , 1 ) ;
278+ if ( newCodePointIndex <= codePointCursor ) {
279+ return cursor ;
280280 }
281+ cursor = source .offsetByCodePoints (cursor , newCodePointIndex - codePointCursor );
282+ codePointCursor = newCodePointIndex ;
281283 return cursor ;
282284 }
283285
Original file line number Diff line number Diff line change @@ -441,9 +441,11 @@ private Space prefix(Token token) {
441441 }
442442
443443 public int advanceCursor (int newCodePointIndex ) {
444- for (; codePointCursor < newCodePointIndex ; codePointCursor ++ ) {
445- cursor = source . offsetByCodePoints ( cursor , 1 ) ;
444+ if ( newCodePointIndex <= codePointCursor ) {
445+ return cursor ;
446446 }
447+ cursor = source .offsetByCodePoints (cursor , newCodePointIndex - codePointCursor );
448+ codePointCursor = newCodePointIndex ;
447449 return cursor ;
448450 }
449451
Original file line number Diff line number Diff line change @@ -467,9 +467,11 @@ private String prefix(Token token) {
467467 */
468468 @ SuppressWarnings ("UnusedReturnValue" )
469469 private int advanceCursor (int newCodePointIndex ) {
470- for (; codePointCursor < newCodePointIndex ; codePointCursor ++ ) {
471- cursor = source . offsetByCodePoints ( cursor , 1 ) ;
470+ if ( newCodePointIndex <= codePointCursor ) {
471+ return cursor ;
472472 }
473+ cursor = source .offsetByCodePoints (cursor , newCodePointIndex - codePointCursor );
474+ codePointCursor = newCodePointIndex ;
473475 return cursor ;
474476 }
475477
You can’t perform that action at this time.
0 commit comments