Data-Flow (Escape) Analysis to Aid in Avoiding GC

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 13 03:31:59 PST 2015


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.


More information about the Digitalmars-d-learn mailing list