__builtins: replace top-level imports with imported#3803
__builtins: replace top-level imports with imported#3803RazvanN7 merged 1 commit intodlang:masterfrom huglovefan:imported_builtins
Conversation
|
Thanks for your pull request and interest in making D better, @huglovefan! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#3803" |
So is the goal to improve compile times?
I think this PR is small enough to let it slide, but in general, please don't mix refactors and bug fixes. |
this way the modules are only imported for code that needs them
|
re-pushed without the c_long fix, will do that separately
something like that (but the difference is probably small) this is an automatically imported file so i thought it would make sense to avoid unnecessary work there the functions using core.bitop already do this by importing the module inside template functions, this does it for the rest of the imports this PR was 50% to see if this would be accepted (it's how i would write the file but unsure what others think), 50% to fix the c_long thing without adding a new top-level import for it (but i see core.stdc.config is already depended upon by one of the current top-level imports so adding it without this PR wouldn't be too bad) |
How? Isn't the global alias going to instantiate the template anyway? |
it works that way in .d files being compiled (listed on dmd command line) but not modules that are just imported like __builtins in imported modules that aren't included in compilation, the template is instantiated only if the importing module uses the alias or a template that uses it, or if the module itself uses it outside a template/alias i don't know if this is documented somewhere but this is how i observe it works |
this way the modules are only imported for code that needs them
this also includes a fix to make(edit: will do separately)__builtin_expectuse c_long since that requires adding an import, it's done using an alias to keep it lazy without having to typeimported!"..."for every usei checked and all the affected functions still work like before
this now doesn't list any
core.stdc.*modules in the output ofdmd -v test.c: