From: Jeroen H. <vex...@gm...> - 2010-11-30 19:51:52
|
Hi, On 30 November 2010 17:38, Dean Michael Berris <mik...@gm...> wrote: > Hi Everyone, > > I recently remembered general advice about how to keep the compile > times down with Spirit.Qi and one of the general tips was to limit the > number of rules you have. The rationale was if you were writing a > parser and had a lot of rule assignments, you were essentially > invoking Proto's evaluation when assigning to a rule. > > I see that the URI code has a lot of rules (>5) which can still be > reduced into a single rule. Jeroen/Glyn can you try and look at > reducing the number of rules and consolidate to just one rule just to > see whether it would help reduce the compile times? > > Thanks in advance and I hope to hear what you guys think about trying > that out. I might do that on my own but getting time lately to work on > cpp-netlib ironically just got really hard. > > -- > Dean Michael Berris > deanberris.com > There is a best practices documentation addendum here: http://boost-spirit.com/home/articles/doc-addendum/best-practices/, which states: "Avoid complex rules. Rules with complex definitions hurt the compiler badly. We’ve seen rules that are more than a hundred lines long and take a couple of minutes to compile. On some compilers, experience shows that the compile time is exponential in relation to the RHS expression length. C++ compilers were not designed to handle such big expressions and some just couldn’t cope (crashes). It is always best to break complex rules into more manageable, easier to digest parts. Doing so also makes the rules more readable." and I've always understood is that multiple simple rules are preferable to a single complex rule. However, if I find time I'll look into combining some rules and testing whether it helps the compile-time, it shouldn't be to hard. Jeroen |