提交 006f5d6b 编写于 作者: J Julius Volz 提交者: GitHub

Merge pull request #68 from prometheus/simplify-equals

Simplify Labels.Equals()
......@@ -84,7 +84,7 @@ func (ls Labels) Equals(o Labels) bool {
return false
}
for i, l := range ls {
if l.Name != o[i].Name || l.Value != o[i].Value {
if o[i] != l {
return false
}
}
......
......@@ -28,7 +28,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestCompare(t *testing.T) {
func TestCompareAndEquals(t *testing.T) {
cases := []struct {
a, b []Label
res int
......@@ -88,6 +88,7 @@ func TestCompare(t *testing.T) {
a, b := New(c.a...), New(c.b...)
require.Equal(t, c.res, Compare(a, b))
require.Equal(t, c.res == 0, a.Equals(b))
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册