struct Location size

Basile B. b2.temp at gmx.com
Tue May 9 08:35:45 UTC 2023


On Tuesday, 9 May 2023 at 00:24:44 UTC, Walter Bright wrote:
> This PR https://github.com/dlang/dmd/pull/15199 reduces its 
> size by 8 bytes, resulting in about 20Mb of memory savings 
> compiling druntime, according to @dkorpel.
>
> [...]
>
> So, for great glory, can anyone come up with a clever scheme 
> that uses only 32 bits?

Yes, call me a madlad but in styx the filename information is in 
the DMD equivalent of `Scope` (and the Loc is 2*32 bits, 
{line,col}). If you do the same in DMD you can reduce the size to 
32 bits, i.e 2*16 bits, {line,col}.

I'm not sure this would work for DMD but for styx the rationale 
was

1. in DMD the size of Loc is a known problem, that's why it's 
usually recommended to pass its instances by ref, let's not have 
the same problem.
2. there's much less Scopes than Loc.



More information about the Digitalmars-d mailing list