Changeset: Use `break` instead of `done` variable

pull/5268/head
Richard Hansen 2021-11-08 23:35:03 -05:00
parent 44d99733c6
commit ca5bdddc59
2 changed files with 6 additions and 10 deletions

View File

@ -285,15 +285,13 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
curLineOpIter = Changeset.opIterator(aLinesGet(curLine)); curLineOpIter = Changeset.opIterator(aLinesGet(curLine));
curLineOpIterLine = curLine; curLineOpIterLine = curLine;
let indexIntoLine = 0; let indexIntoLine = 0;
let done = false; while (curLineOpIter.hasNext()) {
while (!done && curLineOpIter.hasNext()) {
curLineNextOp = curLineOpIter.next(); curLineNextOp = curLineOpIter.next();
if (indexIntoLine + curLineNextOp.chars >= curChar) { if (indexIntoLine + curLineNextOp.chars >= curChar) {
curLineNextOp.chars -= (curChar - indexIntoLine); curLineNextOp.chars -= (curChar - indexIntoLine);
done = true; break;
} else {
indexIntoLine += curLineNextOp.chars;
} }
indexIntoLine += curLineNextOp.chars;
} }
} }

View File

@ -2052,15 +2052,13 @@ exports.inverse = (cs, lines, alines, pool) => {
curLineOpIter = exports.opIterator(alinesGet(curLine)); curLineOpIter = exports.opIterator(alinesGet(curLine));
curLineOpIterLine = curLine; curLineOpIterLine = curLine;
let indexIntoLine = 0; let indexIntoLine = 0;
let done = false; while (curLineOpIter.hasNext()) {
while (!done && curLineOpIter.hasNext()) {
curLineNextOp = curLineOpIter.next(); curLineNextOp = curLineOpIter.next();
if (indexIntoLine + curLineNextOp.chars >= curChar) { if (indexIntoLine + curLineNextOp.chars >= curChar) {
curLineNextOp.chars -= (curChar - indexIntoLine); curLineNextOp.chars -= (curChar - indexIntoLine);
done = true; break;
} else {
indexIntoLine += curLineNextOp.chars;
} }
indexIntoLine += curLineNextOp.chars;
} }
} }