On Wednesday, 3 July 2024 at 11:57:58 UTC, Lance Bachmeier wrote:
On Wednesday, 3 July 2024 at 03:52:41 UTC, Steven Schveighoffer wrote:

And yes, it is faster to do this than appending. But you have to do a *lot* of it to make a huge difference.

What about creating an array of strings and then using join? One obvious problem with this solution is the requirement to specify the size of `buffer`.

It's important to remember that what happens at CTFE is not the same as what happens at runtime. CTFE is a tree-walking interpreter, and does weird things like allocate storage when you change a value. And there is no optimization.

So the best thing to do is try it and see what happens. You can't use your knowledge of how code compiles to judge CTFE performance.

My general feel is that the more code you give to the CTFE interpreter, the worse it gets. Like, try doing `format` in CTFE vs. simple appending it will be vastly different.

-Steve
        • Re: Why does thi... ryuukk_ via Digitalmars-d-learn
          • Re: Why does... drug007 via Digitalmars-d-learn
            • Re: Why... ryuukk_ via Digitalmars-d-learn
              • Re:... drug007 via Digitalmars-d-learn
              • Re:... monkyyy via Digitalmars-d-learn
              • Re:... Dennis via Digitalmars-d-learn
              • Re:... ryuukk_ via Digitalmars-d-learn
              • Re:... Jonathan M Davis via Digitalmars-d-learn
              • Re:... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... Lance Bachmeier via Digitalmars-d-learn
              • Re:... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... ryuukk_ via Digitalmars-d-learn
              • Re:... IchorDev via Digitalmars-d-learn
              • Re:... Stefan Koch via Digitalmars-d-learn
              • Re:... IchorDev via Digitalmars-d-learn
              • Re:... Stefan Koch via Digitalmars-d-learn
  • Re: Why does this mixin fail ... cc via Digitalmars-d-learn

Reply via email to