D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16495 - __traits(fullyQualifedName) instead of std.traits.fullyQualifiedName
Summary: __traits(fullyQualifedName) instead of std.traits.fullyQualifiedName
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2016-09-15 08:09 UTC by Ethan Watson
Modified: 2023-01-22 05:35 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ethan Watson 2016-09-15 08:09:57 UTC
std.traits.fullyQualifiedName has been identified as a significant slowdown during compile time. The implementation does a whole ton of analysis to reconstruct the requested name.

The compiler already has this information though. Implementing as a trait and rewriting std.traits.fullyQualifiedName to use that will result in a solid speed up of compile times.
Comment 1 basile-z 2019-02-13 05:55:22 UTC
I've added and tested such a new __trait. There are problems when using the raw output as produced by the compiler (Type.toPrettyChars(true) or DSymbol.toPrettyChars)

1. complex combinations of type qualifiers are not like expected by phobos unittests
2. template declarations include the constraints
3. handling of single template parameter (so w/o parens) is different

It's probable that toPrettyChars uses the header gen, which is not adapted to produce the fqn. It's rather used to format the errors.

But 80% of the tests pass.
Comment 2 Stefan Koch 2019-02-13 16:27:18 UTC
I've already tried my hand at this.
https://github.com/UplinkCoder/dmd/tree/fqn_trait
please take what you like from this branch.
Comment 3 basile-z 2019-02-13 17:12:12 UTC
Thanks I was sure you did something (i remember you made a video about the fqn perfs). I'm no surprised to see you didn't use the toPrettyChar but otherwise i see a difference in the way you get the symbol from the arg (for now I do like this https://github.com/Basile-z/dmd/commit/53f87a8575735d17b1a07a5e7d11ce2610d1b505#diff-ebdced6ed94b108576dceefdf3c3e021R1803) and i suspect this wan't working in some cases.

So finally why didn't you make a PR ?
Comment 4 Walter Bright 2022-12-17 14:43:36 UTC
fullyQualifiedName implementation:

https://github.com/dlang/phobos/blob/master/std/traits.d#L565
Comment 5 Walter Bright 2022-12-17 14:54:25 UTC
There might be a way to use a modified toPrettyChars to produce the same thing. Basile-z can you be more specific in the differences?
Comment 6 Dlang Bot 2022-12-18 02:02:07 UTC
@WalterBright created dlang/dmd pull request #14711 "fix Issue 16495 - __traits(fullyQualifedName) instead of std.traits.f…" fixing this issue:

- fix Issue 16495 - __traits(fullyQualifedName) instead of std.traits.fullyQualifiedName

https://github.com/dlang/dmd/pull/14711
Comment 7 Dlang Bot 2023-01-22 05:35:11 UTC
dlang/dmd pull request #14711 "fix Issue 16495 - __traits(fullyQualifedName) instead of std.traits.f…" was merged into master:

- 4dc346fc31d69326c9c7d780c57c92c3a7fa9efe by Walter Bright:
  fix Issue 16495 - __traits(fullyQualifedName) instead of std.traits.fullyQualifiedName

https://github.com/dlang/dmd/pull/14711