From 1d5095cf6789fc26c7eface8b68d747d85dbf02e Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 18 Jul 2019 17:44:47 +0000 Subject: plugin/file: Rename do to walk and cleanup and document (#2987) * plugin/file: Rename do to walk, cleanup and document * This renames Do to Walk to be more inline with Go standards. Also make it return an error instead of a bool. Also give give walk access to rrs. Alternatively e.m could be exported, but just access the map of rrs should work as well. Another alternative would be adding a whole bunch of helper functions, but those need grab and return the data. Just having access to the rrs should be easiest for most Walks. * It adds Type and TypeForWildcard to show the different functions * *Removes* the identical RR check when inserting; this was only done for A, AAAA and MX and not finished; removed under the mantra garbage in garbage out. * Reuses Types to return all the types in an *tree.Elem Signed-off-by: Miek Gieben * better comments Signed-off-by: Miek Gieben --- plugin/file/tree/tree.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'plugin/file/tree/tree.go') diff --git a/plugin/file/tree/tree.go b/plugin/file/tree/tree.go index ed33c09a4..3aeeba4d5 100644 --- a/plugin/file/tree/tree.go +++ b/plugin/file/tree/tree.go @@ -275,7 +275,8 @@ func (n *Node) deleteMax() (root *Node, d int) { return } -// Delete removes rr from the tree, is the node turns empty, that node is deleted with DeleteNode. +// Delete removes all RRs of type rr.Header().Rrtype from e. If after the deletion of rr the node is empty the +// entire node is deleted. func (t *Tree) Delete(rr dns.RR) { if t.Root == nil { return @@ -283,15 +284,13 @@ func (t *Tree) Delete(rr dns.RR) { el, _ := t.Search(rr.Header().Name) if el == nil { - t.deleteNode(rr) return } - // Delete from this element. - empty := el.Delete(rr) - if empty { + el.Delete(rr) + if el.Empty() { t.deleteNode(rr) - return } + return } // DeleteNode deletes the node that matches rr according to Less(). -- cgit v1.2.3