lazy_set: Return set from the _make_set method.

This is done to avoid adding typescript type error checks when this
is converted to typescript.
This commit is contained in:
Priyank Patel 2022-01-09 06:59:08 +00:00 committed by Tim Abbott
parent 84958bf7eb
commit d0c339e772
1 changed files with 7 additions and 5 deletions

View File

@ -49,13 +49,15 @@ export class LazySet {
_make_set() { _make_set() {
if (this.data.set !== undefined) { if (this.data.set !== undefined) {
return; return this.data.set;
} }
this.data = { this.data = {
arr: undefined, arr: undefined,
set: new Set(this.data.arr), set: new Set(this.data.arr),
}; };
return this.data.set;
} }
map(f) { map(f) {
@ -69,15 +71,15 @@ export class LazySet {
} }
add(v) { add(v) {
this._make_set(); const set = this._make_set();
const val = this._clean(v); const val = this._clean(v);
this.data.set.add(val); set.add(val);
} }
delete(v) { delete(v) {
this._make_set(); const set = this._make_set();
const val = this._clean(v); const val = this._clean(v);
return this.data.set.delete(val); return set.delete(val);
} }
_clean(v) { _clean(v) {