Skip to content

Commit 32c114e

Browse files
committed
added some comments
1 parent f0356b8 commit 32c114e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ private int getPos() {
492492
var trackerCount = tracker.getReadCount();
493493

494494
if (readCount < trackerCount) {
495+
// the tracker indicates that `read` has happened and so the buffer has been rewound.
495496
readCount = trackerCount;
497+
// we learn from the tracker how far the offset is until the new first character in the buffer
498+
// and we add the current offset since that reset to found our new current offset.
496499
offset = tracker.getLimitOffset() + internalPos;
497500
}
498501
else {
@@ -504,6 +507,7 @@ private int getPos() {
504507
lastPos = internalPos;
505508

506509
try {
510+
// never go below 0. might happen with a parse error at the first character.
507511
return Math.max(0, offset - 1);
508512
}
509513
catch (IllegalArgumentException | SecurityException e) {

0 commit comments

Comments
 (0)