Inline flatten method

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-07-02 16:12:10 +05:30
parent 53fc6a7af9
commit db515d48c1

View file

@ -3,12 +3,6 @@ export class Disambiguator {
this._map = new Map(); this._map = new Map();
} }
_flatten(name, array) {
const vm = array.pop();
vm.setDisambiguation(false);
this._map.set(name, vm);
}
_unDisambiguate(vm, array) { _unDisambiguate(vm, array) {
const idx = array.indexOf(vm); const idx = array.indexOf(vm);
if (idx !== -1) { if (idx !== -1) {
@ -23,7 +17,11 @@ export class Disambiguator {
const value = this._map.get(previousName); const value = this._map.get(previousName);
if (Array.isArray(value)) { if (Array.isArray(value)) {
this._unDisambiguate(vm, value); this._unDisambiguate(vm, value);
if (value.length === 1) { this._flatten(previousName, value); } if (value.length === 1) {
const vm = value[0];
vm.setDisambiguation(false);
this._map.set(previousName, vm);
}
} else { } else {
this._map.delete(previousName); this._map.delete(previousName);
} }