Skip to content

Commit

Permalink
optimize append, set skip if prepareChar returns empty
Browse files Browse the repository at this point in the history
  • Loading branch information
uNmAnNeR committed Jul 20, 2023
1 parent 0256f08 commit 32f7374
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/imask/src/core/change-details.ts
Expand Up @@ -15,7 +15,7 @@ class ChangeDetails {
/** Inserted symbols */
declare inserted: string;
/** Can skip chars */
declare skip: boolean;
declare skip?: boolean;
/** Additional offset if any changes occurred before tail */
declare tailShift: number;
/** Raw inserted is used by dynamic mask */
Expand All @@ -32,7 +32,6 @@ class ChangeDetails {
Object.assign(this, {
inserted: '',
rawInserted: '',
skip: false,
tailShift: 0,
}, details);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/imask/src/masked/base.ts
Expand Up @@ -220,7 +220,11 @@ abstract class Masked<Value=any> {
let details: ChangeDetails;
[ch, details] = this.doPrepareChar(ch, flags);

details = details.aggregate(this._appendCharRaw(ch, flags));
if (ch) {
details = details.aggregate(this._appendCharRaw(ch, flags));
} else if (details.skip == null) {
details.skip = true;
}

if (details.inserted) {
let consistentTail;
Expand Down

0 comments on commit 32f7374

Please sign in to comment.