simplify return eval

This commit is contained in:
Jörg Breitbart
2021-01-21 11:38:47 +01:00
parent c50c134e25
commit d67faff92a
3 changed files with 21 additions and 6 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ export class DcsParser implements IDcsParser {
} else { } else {
let j = this._active.length - 1; let j = this._active.length - 1;
for (; j >= 0; j--) { for (; j >= 0; j--) {
if (this._active[j].unhook(success) !== false) { if (this._active[j].unhook(success)) {
break; break;
} }
} }
+19 -4
View File
@@ -521,8 +521,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
const handlers = this._csiHandlers[collect << 8 | code]; const handlers = this._csiHandlers[collect << 8 | code];
let j = handlers ? handlers.length - 1 : -1; let j = handlers ? handlers.length - 1 : -1;
for (; j >= 0; j--) { for (; j >= 0; j--) {
// undefined or true means success and to stop bubbling // true means success and to stop bubbling
if (handlers[j](params) !== false) { if (handlers[j](params)) {
break; break;
} }
} }
@@ -555,8 +555,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
const handlersEsc = this._escHandlers[collect << 8 | code]; const handlersEsc = this._escHandlers[collect << 8 | code];
let jj = handlersEsc ? handlersEsc.length - 1 : -1; let jj = handlersEsc ? handlersEsc.length - 1 : -1;
for (; jj >= 0; jj--) { for (; jj >= 0; jj--) {
// undefined or true means success and to stop bubbling // true means success and to stop bubbling
if (handlersEsc[jj]() !== false) { if (handlersEsc[jj]()) {
break; break;
} }
} }
@@ -582,6 +582,21 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
i = j - 1; i = j - 1;
break; break;
} }
if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) {
dcs.put(data, i, j);
i = j - 1;
break;
}
if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) {
dcs.put(data, i, j);
i = j - 1;
break;
}
if (++j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) {
dcs.put(data, i, j);
i = j - 1;
break;
}
} }
break; break;
case ParserAction.DCS_UNHOOK: case ParserAction.DCS_UNHOOK:
+1 -1
View File
@@ -83,7 +83,7 @@ export class OscParser implements IOscParser {
} else { } else {
let j = handlers.length - 1; let j = handlers.length - 1;
for (; j >= 0; j--) { for (; j >= 0; j--) {
if (handlers[j].end(success) !== false) { if (handlers[j].end(success)) {
break; break;
} }
} }