Skip to content

Commit

Permalink
Trie.remove(nonexistent-node) is a no-op
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jan 26, 2017
1 parent 815c248 commit 8ccdae9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/trie.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ URLTrie.prototype.remove = function (path) {
}
var part = path.shift();
var child = this.branches[part];
if (child === undefined) {
// Requested node doesn't exist,
// consider it already removed.
return;

child.remove(path);
if (child.size === 0 && child.data === undefined) {
// child has no branches and is not a leaf
Expand Down

0 comments on commit 8ccdae9

Please sign in to comment.