mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-05 04:11:59 +00:00
util/deephash: simplify canMemHash (#5384)
Put the t.Size() == 0 check first since this is applicable in all cases. Drop the last struct field conditional since this is covered by the sumFieldSize check at the end. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
@@ -379,20 +379,18 @@ func TestCanMemHash(t *testing.T) {
|
||||
_ uint8
|
||||
_ int
|
||||
}{}, false}, // gap
|
||||
{
|
||||
struct {
|
||||
_ structs.Incomparable // if not last, zero-width
|
||||
x int
|
||||
}{},
|
||||
true,
|
||||
},
|
||||
{
|
||||
struct {
|
||||
x int
|
||||
_ structs.Incomparable // zero-width last: has space, can't memhash
|
||||
}{},
|
||||
false,
|
||||
}}
|
||||
{struct {
|
||||
_ structs.Incomparable // if not last, zero-width
|
||||
x int
|
||||
}{}, true},
|
||||
{struct {
|
||||
x int
|
||||
_ structs.Incomparable // zero-width last: has space, can't memhash
|
||||
}{},
|
||||
false},
|
||||
{[0]chan bool{}, true},
|
||||
{struct{ f [0]func() }{}, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := canMemHash(reflect.TypeOf(tt.val))
|
||||
if got != tt.want {
|
||||
|
||||
Reference in New Issue
Block a user