On Friday, 13 February 2015 at 08:21:53 UTC, Per Nordlöw wrote:
When reading/parsing data from disk often try to write code such as

    foreach (const line; File(filePath).byLine)
    {
        auto s = line.splitter(" ")

        const x = s.front.to!uint; s.popFront;
        const y = s.front.to!double; s.popFront;
        ...
    }

In response to all the discussions regarding performance problems related to the GC I wonder if there are plans to implement data-flow analysis in DMD that can detect that the calls to s.front in the example above doesn't need to use the GC. This because their references aren't used outside of the foreach scope (Escape Analysis).

I haven't looked into the source, but the only point where this snippet should allocate is at byLine.

Reply via email to