Performance optimization removing dump

This commit is contained in:
Paulo Gustavo Veiga 2022-02-18 15:41:21 -08:00
parent 72018cf6b0
commit 987a271e93

View File

@ -55,10 +55,9 @@ class RootedTreeSet {
*/ */
add(node: Node) { add(node: Node) {
$assert(node, 'node can not be null'); $assert(node, 'node can not be null');
$assert( if (this.find(node.getId(), false)) {
!this.find(node.getId(), false), throw new Error(`node already exits with this id. Id:${node.getId()}: ${this.dump()}`);
`node already exits with this id. Id:${node.getId()}: ${this.dump()}`, }
);
$assert(!node._children, 'node already added'); $assert(!node._children, 'node already added');
this._rootNodes.push(this._decodate(node)); this._rootNodes.push(this._decodate(node));
} }
@ -130,10 +129,11 @@ class RootedTreeSet {
break; break;
} }
} }
$assert(
validate ? result : true, if (validate && !result) {
`node could not be found id:${id}\n,RootedTreeSet${this.dump()}`, throw new Error(`node could not be found id:${id}\n,RootedTreeSet${this.dump()}`);
); }
return result; return result;
} }
@ -258,8 +258,8 @@ class RootedTreeSet {
} }
/** /**
* @return result * @return result
*/ */
dump() { dump() {
const branches = this._rootNodes; const branches = this._rootNodes;
let result = ''; let result = '';