www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12844] New: Absurd RAM Required for ctRegex

https://issues.dlang.org/show_bug.cgi?id=12844

          Issue ID: 12844
           Summary: Absurd RAM Required for ctRegex
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Keywords: CTFE, performance
          Severity: major
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: blah38621 gmail.com

Currently both git head and 2.065 take an utterly absurd (I killed DMD's 
process at 9.5gb of ram usage, I only have 16gb of RAM so I can't test further 
than that) amount of RAM to compile the following code:

module main;

import std.file : readText, write;
import std.math : round;
import std.regex;

enum planePattern = ctRegex!(`"plane" "\(([-]?[0-9]+(?:\.[0-9]+)? 
[-]?[0-9]+(?:\.[0-9]+)? [-]?[0-9]+(?:\.[0-9]+)?)\) \(([-]?[0-9]+(?:\.[0-9]+)? 
[-]?[0-9]+(?:\.[0-9]+)? [-]?[0-9]+(?:\.[0-9]+)?)\) \(([-]?[0-9]+(?:\.[0-9]+)? 
[-]?[0-9]+(?:\.[0-9]+)? [-]?[0-9]+(?:\.[0-9]+)?)\)"`, "g");

void main(string[] args)
{
    import std.stdio;

    string dat = readText(args[0]);

    foreach (m; planePattern.matchAll(dat))
    {
        writeln(m);
    }
}

--
Jun 02 2014