Skip to content

Commit 948cf8c

Browse files
committed
refactor
1 parent 742e157 commit 948cf8c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tftypes/value.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,31 +577,32 @@ func (val Value) IsNull() bool {
577577
// IsFullyNull returns true if the Value is null or if the Value is an
578578
// aggregate that consists of only fully null elements and attributes.
579579
func (val Value) IsFullyNull() bool {
580+
if val.IsNull() {
581+
return true
582+
}
583+
580584
switch val.Type().(type) {
581585
case primitive:
582-
return val.IsNull()
586+
return false // already checked IsNull() and not an aggregate
587+
583588
case List, Set, Tuple:
584-
sliceVal, ok := val.value.([]Value)
585-
if !ok {
586-
return true
587-
}
589+
sliceVal := val.value.([]Value)
588590
for _, v := range sliceVal {
589591
if !v.IsFullyNull() {
590592
return false
591593
}
592594
}
593595
return true
596+
594597
case Map, Object:
595-
mapVal, ok := val.value.(map[string]Value)
596-
if !ok {
597-
return true
598-
}
598+
mapVal := val.value.(map[string]Value)
599599
for _, v := range mapVal {
600600
if !v.IsFullyNull() {
601601
return false
602602
}
603603
}
604604
return true
605+
605606
default:
606607
panic(fmt.Sprintf("unknown type %T", val.Type()))
607608
}

0 commit comments

Comments
 (0)