8
8
"fmt"
9
9
"go/constant"
10
10
"go/token"
11
+ "internal/abi"
11
12
"strings"
12
13
13
14
"cmd/compile/internal/base"
@@ -321,7 +322,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
321
322
// Maximum key and elem size is 128 bytes, larger objects
322
323
// are stored with an indirection. So max bucket size is 2048+eps.
323
324
if ! ir .IsConst (hint , constant .Int ) ||
324
- constant .Compare (hint .Val (), token .LEQ , constant .MakeInt64 (reflectdata . BUCKETSIZE )) {
325
+ constant .Compare (hint .Val (), token .LEQ , constant .MakeInt64 (abi . MapBucketCount )) {
325
326
326
327
// In case hint is larger than BUCKETSIZE runtime.makemap
327
328
// will allocate the buckets on the heap, see #20184
@@ -332,7 +333,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
332
333
// h.buckets = b
333
334
// }
334
335
335
- nif := ir .NewIfStmt (base .Pos , ir .NewBinaryExpr (base .Pos , ir .OLE , hint , ir .NewInt (base .Pos , reflectdata . BUCKETSIZE )), nil , nil )
336
+ nif := ir .NewIfStmt (base .Pos , ir .NewBinaryExpr (base .Pos , ir .OLE , hint , ir .NewInt (base .Pos , abi . MapBucketCount )), nil , nil )
336
337
nif .Likely = true
337
338
338
339
// var bv bmap
@@ -347,7 +348,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
347
348
}
348
349
}
349
350
350
- if ir .IsConst (hint , constant .Int ) && constant .Compare (hint .Val (), token .LEQ , constant .MakeInt64 (reflectdata . BUCKETSIZE )) {
351
+ if ir .IsConst (hint , constant .Int ) && constant .Compare (hint .Val (), token .LEQ , constant .MakeInt64 (abi . MapBucketCount )) {
351
352
// Handling make(map[any]any) and
352
353
// make(map[any]any, hint) where hint <= BUCKETSIZE
353
354
// special allows for faster map initialization and
0 commit comments