On Sunday, 31 December 2023 at 11:07:53 UTC, Johan wrote:
>On Sunday, 31 December 2023 at 08:25:33 UTC, Walter Bright wrote:
>- return an InputRange rather than an array of lines
- no longer do any memory allocation (yay!)
- no more leaking memory
- stops processing the source text when the desired line is found
- support Unicode line endings
- uses Voldemort return value
- is pure, @safe, @nogc and all that good stuff
- much faster
- completely self-contained
https://github.com/dlang/dmd/pull/15972
and that doesn't even include an earlier refactor:
https://github.com/dlang/dmd/pull/15969
I eyeballed std.string.splitLines() when doing this refactor, and noticed that it also allocated memory unnecessarily.
It's more lines of code, but the lines are simpler, and there's not a clever thing in it!
Nice. Even better if you'd have used std.string.splitLines !
Or more like https://dlang.org/library/std/string/line_splitter.html for having no allocations and @nogc
compatibility.
The listed benefits are nice and very much welcome, but it's a copy-paste job from Phobos into the DMD codebase. Raising a question again about the reasons why DMD itself isn't using Phobos like any normal applications do.
Also whenever game developers are complaining in this forum about poor @nogc
support, they are being told that the GC is totally fine and they are just unreasonably biased against it. All of this while the DMD compiler itself is doing fancy hackish stunts with memory allocation. Games are latency sensitive. Compilers are not.
That would have solved your point 9; self-contained == not maintained (as proven by the long standing Unicode line ending bug).
Regarding copy-pasting code into multiple places and maintaining it separately, LDC developers fixed https://issues.dlang.org/show_bug.cgi?id=24290 for themselves, but haven't contributed the fix back to DMD.