Skip to content
This repository
Browse code

shave off 4 seconds from xml_node.cpp compile time (16 -> 12) by movi…

…ng transform grammar to cpp - refs #1267
  • Loading branch information...
commit 29deca8db89cbc9d6d86c947907f209614393ebc 1 parent 2ba016b
Dane Springmeyer authored July 23, 2012
60  include/mapnik/transform_expression_grammar.hpp
@@ -39,65 +39,7 @@ namespace mapnik {
39 39
     struct transform_expression_grammar
40 40
         : qi::grammar<Iterator, transform_list(), space_type>
41 41
     {
42  
-        explicit transform_expression_grammar(expression_grammar<Iterator> const& g)
43  
-            : transform_expression_grammar::base_type(start)
44  
-        {
45  
-            using boost::phoenix::construct;
46  
-            using qi::_a; using qi::_1; using qi::_4;
47  
-            using qi::_b; using qi::_2; using qi::_5;
48  
-            using qi::_c; using qi::_3; using qi::_6;
49  
-            using qi::_val;
50  
-            using qi::char_;
51  
-            using qi::lit;
52  
-            using qi::no_case;
53  
-            using qi::no_skip;
54  
-
55  
-            start = transform_ % no_skip[char_(", ")] ;
56  
-
57  
-            transform_ = matrix | translate | scale | rotate | skewX | skewY ;
58  
-
59  
-            matrix = no_case[lit("matrix")]
60  
-                >> (lit('(')
61  
-                    >> expr >> -lit(',')
62  
-                    >> expr >> -lit(',')
63  
-                    >> expr >> -lit(',')
64  
-                    >> expr >> -lit(',')
65  
-                    >> expr >> -lit(',')
66  
-                    >> expr >>  lit(')'))
67  
-                [ _val = construct<matrix_node>(_1,_2,_3,_4,_5,_6) ];
68  
-
69  
-            translate = no_case[lit("translate")]
70  
-                >> (lit('(')
71  
-                    >> expr >> -lit(',')
72  
-                    >> -expr >> lit(')'))
73  
-                [ _val = construct<translate_node>(_1,_2) ];
74  
-
75  
-            scale = no_case[lit("scale")]
76  
-                >> (lit('(')
77  
-                    >> expr >> -lit(',')
78  
-                    >> -expr >> lit(')'))
79  
-                [ _val = construct<scale_node>(_1,_2) ];
80  
-
81  
-            rotate = no_case[lit("rotate")]
82  
-                >> lit('(')
83  
-                >> expr[_a = _1] >> -lit(',')
84  
-                >> -(expr [_b = _1] >> -lit(',') >> expr[_c = _1])
85  
-                >> lit(')')
86  
-                [ _val = construct<rotate_node>(_a,_b,_c) ];
87  
-
88  
-            skewX = no_case[lit("skewX")]
89  
-                >> lit('(')
90  
-                >> expr [ _val = construct<skewX_node>(_1) ]
91  
-                >> lit(')');
92  
-
93  
-            skewY = no_case[lit("skewY")]
94  
-                >> lit('(')
95  
-                >> expr [ _val = construct<skewY_node>(_1) ]
96  
-                >> lit(')');
97  
-
98  
-            expr = g.expr.alias();
99  
-        }
100  
-
  42
+        explicit transform_expression_grammar(expression_grammar<Iterator> const& g);
101 43
         typedef qi::locals<expr_node, boost::optional<expr_node>,
102 44
                                       boost::optional<expr_node>
103 45
                           > rotate_locals;
1  src/build.py
@@ -113,6 +113,7 @@ def ldconfig(*args,**kwargs):
113 113
     expression_grammar.cpp
114 114
     expression_string.cpp
115 115
     expression.cpp
  116
+    transform_expression_grammar.cpp
116 117
     transform_expression.cpp
117 118
     feature_kv_iterator.cpp
118 119
     feature_type_style.cpp
91  src/transform_expression_grammar.cpp
... ...
@@ -0,0 +1,91 @@
  1
+/*****************************************************************************
  2
+ *
  3
+ * This file is part of Mapnik (c++ mapping toolkit)
  4
+ *
  5
+ * Copyright (C) 2012 Artem Pavlenko
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ *****************************************************************************/
  22
+ 
  23
+#include <mapnik/transform_expression_grammar.hpp>
  24
+
  25
+namespace mapnik {
  26
+
  27
+namespace qi = boost::spirit::qi;
  28
+
  29
+template <typename Iterator>
  30
+transform_expression_grammar<Iterator>::transform_expression_grammar(expression_grammar<Iterator> const& g)
  31
+        : transform_expression_grammar::base_type(start)
  32
+{
  33
+    using boost::phoenix::construct;
  34
+    using qi::_a; using qi::_1; using qi::_4;
  35
+    using qi::_b; using qi::_2; using qi::_5;
  36
+    using qi::_c; using qi::_3; using qi::_6;
  37
+    using qi::_val;
  38
+    using qi::char_;
  39
+    using qi::lit;
  40
+    using qi::no_case;
  41
+    using qi::no_skip;
  42
+
  43
+    start = transform_ % no_skip[char_(", ")] ;
  44
+
  45
+    transform_ = matrix | translate | scale | rotate | skewX | skewY ;
  46
+
  47
+    matrix = no_case[lit("matrix")]
  48
+        >> (lit('(')
  49
+            >> expr >> -lit(',')
  50
+            >> expr >> -lit(',')
  51
+            >> expr >> -lit(',')
  52
+            >> expr >> -lit(',')
  53
+            >> expr >> -lit(',')
  54
+            >> expr >>  lit(')'))
  55
+        [ _val = construct<matrix_node>(_1,_2,_3,_4,_5,_6) ];
  56
+
  57
+    translate = no_case[lit("translate")]
  58
+        >> (lit('(')
  59
+            >> expr >> -lit(',')
  60
+            >> -expr >> lit(')'))
  61
+        [ _val = construct<translate_node>(_1,_2) ];
  62
+
  63
+    scale = no_case[lit("scale")]
  64
+        >> (lit('(')
  65
+            >> expr >> -lit(',')
  66
+            >> -expr >> lit(')'))
  67
+        [ _val = construct<scale_node>(_1,_2) ];
  68
+
  69
+    rotate = no_case[lit("rotate")]
  70
+        >> lit('(')
  71
+        >> expr[_a = _1] >> -lit(',')
  72
+        >> -(expr [_b = _1] >> -lit(',') >> expr[_c = _1])
  73
+        >> lit(')')
  74
+        [ _val = construct<rotate_node>(_a,_b,_c) ];
  75
+
  76
+    skewX = no_case[lit("skewX")]
  77
+        >> lit('(')
  78
+        >> expr [ _val = construct<skewX_node>(_1) ]
  79
+        >> lit(')');
  80
+
  81
+    skewY = no_case[lit("skewY")]
  82
+        >> lit('(')
  83
+        >> expr [ _val = construct<skewY_node>(_1) ]
  84
+        >> lit(')');
  85
+
  86
+    expr = g.expr.alias();
  87
+}
  88
+
  89
+template struct mapnik::transform_expression_grammar<std::string::const_iterator>;
  90
+
  91
+}

0 notes on commit 29deca8

Please sign in to comment.
Something went wrong with that request. Please try again.