From 06ff82c73d1996a3823e4163d762506178f04a24 Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Mon, 22 Dec 2025 17:09:16 +0100 Subject: [PATCH] Redefine `__traits(getPointerBitmap, S)` for types without pointers to return size only. This greatly reduces compile time for large types without pointers, because no need to create a large array literal with zeros. --- spec/traits.dd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/traits.dd b/spec/traits.dd index b7c100e6d7..49dac7c0f7 100644 --- a/spec/traits.dd +++ b/spec/traits.dd @@ -560,7 +560,7 @@ $(H3 $(GNAME getPointerBitmap)) ) $(P The first element of the array is the size of the type (for classes it is the $(GLINK classInstanceSize)).) - $(P The following elements describe the locations of GC managed pointers within the + $(P If the type contains pointers, then the following elements describe the locations of GC managed pointers within the memory occupied by an instance of the type. For type T, there are $(D T.sizeof / size_t.sizeof) possible pointers represented by the bits of the array values.) @@ -588,8 +588,14 @@ void main() void delegate () dg; // { context, func } } + static struct S_no_pointers + { + int[200000000] x; + } + static assert (__traits(getPointerBitmap, C) == [6*size_t.sizeof, 0b010100]); static assert (__traits(getPointerBitmap, S) == [7*size_t.sizeof, 0b0110110]); + static assert (__traits(getPointerBitmap, S_no_pointers) == [200000000*int.sizeof]); } --- )