Skip to content

Comments

Optimize AliasAssign tuple building#14332

Merged
dlang-bot merged 1 commit intodlang:masterfrom
BorisCarvajal:opti_aliasassign_seq
Jul 28, 2022
Merged

Optimize AliasAssign tuple building#14332
dlang-bot merged 1 commit intodlang:masterfrom
BorisCarvajal:opti_aliasassign_seq

Conversation

@BorisCarvajal
Copy link
Member

Try to remove some quadratic behavior by expanding AliasSeq elements only in the target AliasDeclaration.

A synthetic test:

alias AliasSeq(T...) = T;
template Count(size_t l)
{
    alias Count = AliasSeq!();
    static foreach (i; 0 .. l)
        Count = AliasSeq!(Count, i);
}
alias c = Count!10000;
static assert(c.length == 10000);
static assert(c[0..5]   == AliasSeq!(0,1,2,3,4));
static assert(c[$-5..$] == AliasSeq!(9995,9996,9997,9998,9999));

Compilation time, memory usage. (just using /usr/bin/time -v dmd -o- test.d)
before: 6.66 sec. 815MB
after: 0.07 sec. 45MB

@BorisCarvajal BorisCarvajal requested a review from ibuclaw as a code owner July 26, 2022 10:48
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @BorisCarvajal!

Bugzilla references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14332"

@BorisCarvajal BorisCarvajal force-pushed the opti_aliasassign_seq branch 2 times, most recently from 87c741e to 96c8644 Compare July 27, 2022 02:55
@BorisCarvajal BorisCarvajal force-pushed the opti_aliasassign_seq branch 2 times, most recently from d4aca91 to 6f92604 Compare July 27, 2022 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants