Skip to content

Commit

Permalink
Merge pull request #4 from muyiwaolurin/master
Browse files Browse the repository at this point in the history
Unreachable code section
  • Loading branch information
armon committed Jan 15, 2016
2 parents fbd82e8 + 6e88641 commit 4239b77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
18 changes: 8 additions & 10 deletions radix.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ func (t *Tree) Insert(s string, v interface{}) (interface{}, bool) {
old := n.leaf.val
n.leaf.val = v
return old, true
} else {
n.leaf = &leafNode{
key: s,
val: v,
}
t.size++
return nil, false
}

n.leaf = &leafNode{
key: s,
val: v,
}
t.size++
return nil, false
}

// Look for the edge
Expand Down Expand Up @@ -233,7 +233,6 @@ func (t *Tree) Insert(s string, v interface{}) (interface{}, bool) {
})
return nil, false
}
return nil, false
}

// Delete is used to delete a key, returning the previous
Expand Down Expand Up @@ -393,9 +392,8 @@ func (t *Tree) Maximum() (string, interface{}, bool) {
}
if n.isLeaf() {
return n.leaf.key, n.leaf.val, true
} else {
break
}
break
}
return "", nil, false
}
Expand Down
36 changes: 18 additions & 18 deletions radix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,43 +174,43 @@ func TestWalkPrefix(t *testing.T) {
out []string
}
cases := []exp{
exp{
{
"f",
[]string{"foobar", "foo/bar/baz", "foo/baz/bar", "foo/zip/zap"},
},
exp{
{
"foo",
[]string{"foobar", "foo/bar/baz", "foo/baz/bar", "foo/zip/zap"},
},
exp{
{
"foob",
[]string{"foobar"},
},
exp{
{
"foo/",
[]string{"foo/bar/baz", "foo/baz/bar", "foo/zip/zap"},
},
exp{
{
"foo/b",
[]string{"foo/bar/baz", "foo/baz/bar"},
},
exp{
{
"foo/ba",
[]string{"foo/bar/baz", "foo/baz/bar"},
},
exp{
{
"foo/bar",
[]string{"foo/bar/baz"},
},
exp{
{
"foo/bar/baz",
[]string{"foo/bar/baz"},
},
exp{
{
"foo/bar/bazoo",
[]string{},
},
exp{
{
"z",
[]string{"zipzap"},
},
Expand Down Expand Up @@ -254,35 +254,35 @@ func TestWalkPath(t *testing.T) {
out []string
}
cases := []exp{
exp{
{
"f",
[]string{},
},
exp{
{
"foo",
[]string{"foo"},
},
exp{
{
"foo/",
[]string{"foo"},
},
exp{
{
"foo/ba",
[]string{"foo"},
},
exp{
{
"foo/bar",
[]string{"foo", "foo/bar"},
},
exp{
{
"foo/bar/baz",
[]string{"foo", "foo/bar", "foo/bar/baz"},
},
exp{
{
"foo/bar/bazoo",
[]string{"foo", "foo/bar", "foo/bar/baz"},
},
exp{
{
"z",
[]string{},
},
Expand Down

0 comments on commit 4239b77

Please sign in to comment.