Skip to content

Commit cf5ec07

Browse files
prattmicgopherbot
authored andcommitted
cmd/compile: remove types.Compare map bucket special cases
runtime.hmap never directly refers to the bucket type (it uses an unsafe.Pointer), thus it shouldn't be possible to have infinite recursion here. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race,gotip-linux-amd64-longtest-aliastypeparams Change-Id: I457885e48bbc352acedae1c0c389078f39ed9d65 Reviewed-on: https://go-review.googlesource.com/c/go/+/619037 Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Michael Pratt <[email protected]>
1 parent a947912 commit cf5ec07

File tree

1 file changed

+14
-14
lines changed
  • src/cmd/compile/internal/types

1 file changed

+14
-14
lines changed

src/cmd/compile/internal/types/type.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,35 +1190,35 @@ func (t *Type) cmp(x *Type) Cmp {
11901190

11911191
case TSTRUCT:
11921192
if buildcfg.Experiment.SwissMap {
1193+
// Is this a map group type?
11931194
if t.StructType().Map == nil {
11941195
if x.StructType().Map != nil {
11951196
return CMPlt // nil < non-nil
11961197
}
11971198
// to the fallthrough
11981199
} else if x.StructType().Map == nil {
11991200
return CMPgt // nil > non-nil
1200-
} else {
1201-
// TODO: I am confused by the purpose of the OldBucket stuff below.
1202-
return t.StructType().Map.cmp(x.StructType().Map)
1203-
} // If t != t.Map.SwissBucket, fall through to general case
1201+
}
1202+
// Both have non-nil Map, fallthrough to the general
1203+
// case. Note that the map type does not directly refer
1204+
// to the group type (it uses unsafe.Pointer). If it
1205+
// did, this would need special handling to avoid
1206+
// infinite recursion.
12041207
} else {
1208+
// Is this a map bucket type?
12051209
if t.StructType().Map == nil {
12061210
if x.StructType().Map != nil {
12071211
return CMPlt // nil < non-nil
12081212
}
12091213
// to the fallthrough
12101214
} else if x.StructType().Map == nil {
12111215
return CMPgt // nil > non-nil
1212-
} else if t.StructType().Map.MapType().OldBucket == t {
1213-
// Both have non-nil Map
1214-
// Special case for Maps which include a recursive type where the recursion is not broken with a named type
1215-
if x.StructType().Map.MapType().OldBucket != x {
1216-
return CMPlt // bucket maps are least
1217-
}
1218-
return t.StructType().Map.cmp(x.StructType().Map)
1219-
} else if x.StructType().Map.MapType().OldBucket == x {
1220-
return CMPgt // bucket maps are least
1221-
} // If t != t.Map.OldBucket, fall through to general case
1216+
}
1217+
// Both have non-nil Map, fallthrough to the general
1218+
// case. Note that the map type does not directly refer
1219+
// to the bucket type (it uses unsafe.Pointer). If it
1220+
// did, this would need special handling to avoid
1221+
// infinite recursion.
12221222
}
12231223

12241224
tfs := t.Fields()

0 commit comments

Comments
 (0)