]> granicus.if.org Git - re2c/commitdiff
Reduced redundant parameter.
authorUlya Trofimovich <skvadrik@gmail.com>
Tue, 17 Mar 2015 16:24:46 +0000 (16:24 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 17 Mar 2015 16:24:46 +0000 (16:24 +0000)
re2c/code.cc
re2c/go.cc
re2c/go.h

index 9d4e633d9b38b2c7cd5cca22a93fb3543881738a..1ecc03572a3f259ae6d149e40b282929ae7f7566 100644 (file)
@@ -1117,7 +1117,7 @@ void DFA::emit(Output & output, uint& ind, const RegExpMap* specMap, const std::
 
        for (s = head; s; s = s->next)
        {
-               s->go.init (s, s->next);
+               s->go.init (s);
        }
 
 /*
index 49bcb64aa412f3b00e3332b8f0f5763e3d48d15c..06fa4dcacd801a88627b404ebf24a96c1b3fcfc6 100644 (file)
@@ -148,10 +148,10 @@ Cond::Cond (const std::string & cmp, uint val)
        , value (val)
 {}
 
-Binary::Binary (const Span * s, uint n, const State * from, const State * next)
+Binary::Binary (const Span * s, uint n, const State * next)
        : cond (new Cond ("<=", s[n / 2 - 1].ub - 1))
-       , thn (new If (n / 2 > 4 ? If::BINARY : If::LINEAR, &s[0], n / 2, from, next))
-       , els (new If (n - n / 2 > 4 ? If::BINARY : If::LINEAR, &s[n / 2], n - n / 2, from, next))
+       , thn (new If (n / 2 > 4 ? If::BINARY : If::LINEAR, &s[0], n / 2, next))
+       , els (new If (n - n / 2 > 4 ? If::BINARY : If::LINEAR, &s[n / 2], n - n / 2, next))
 {}
 
 void Binary::emit (OutputFile & o, uint ind, bool & readCh)
@@ -164,7 +164,7 @@ void Binary::emit (OutputFile & o, uint ind, bool & readCh)
        o << indent (ind) << "}\n";
 }
 
-Linear::Linear (const Span * s, uint n, const State * from, const State * next)
+Linear::Linear (const Span * s, uint n, const State * next)
        : branches ()
 {
        for (;;)
@@ -186,8 +186,7 @@ Linear::Linear (const Span * s, uint n, const State * from, const State * next)
                }
                if (n == 1)
                {
-                       if (s[0].to->label != from->label + 1)
-//                     if (s[0].to->next && s[0].to->label != s[0].to->next->label + 1)
+                       if (next == NULL || s[0].to->label != next->label)
                        {
                                branches.push_back (std::make_pair (static_cast<const Cond *> (NULL), s[0].to));
                        }
@@ -223,17 +222,17 @@ void Linear::emit (OutputFile & o, uint ind, bool & readCh)
        }
 }
 
-If::If (type_t t, const Span * sp, uint nsp, const State * from, const State * next)
+If::If (type_t t, const Span * sp, uint nsp, const State * next)
        : type (t)
        , info ()
 {
        switch (type)
        {
                case BINARY:
-                       info.binary = new Binary (sp, nsp, from, next);
+                       info.binary = new Binary (sp, nsp, next);
                        break;
                case LINEAR:
-                       info.linear = new Linear (sp, nsp, from, next);
+                       info.linear = new Linear (sp, nsp, next);
                        break;
        }
 }
@@ -251,7 +250,7 @@ void If::emit (OutputFile & o, uint ind, bool & readCh)
        }
 }
 
-SwitchIf::SwitchIf (const Span * sp, uint nsp, const State * from, const State * next)
+SwitchIf::SwitchIf (const Span * sp, uint nsp, const State * next)
        : type (IF)
        , info ()
 {
@@ -262,11 +261,11 @@ SwitchIf::SwitchIf (const Span * sp, uint nsp, const State * from, const State *
        }
        else if (nsp > 5)
        {
-               info.ifs = new If (If::BINARY, sp, nsp, from, next);
+               info.ifs = new If (If::BINARY, sp, nsp, next);
        }
        else
        {
-               info.ifs = new If (If::LINEAR, sp, nsp, from, next);
+               info.ifs = new If (If::LINEAR, sp, nsp, next);
        }
 }
 
@@ -283,17 +282,17 @@ void SwitchIf::emit (OutputFile & o, uint ind, bool & readCh)
        }
 }
 
-Bitmap::Bitmap (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const BitMap * bm, const State * bm_state, const State * from, const State * next)
+Bitmap::Bitmap (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const BitMap * bm, const State * bm_state, const State * next)
        : bitmap (bm)
        , bitmap_state (bm_state)
-       , hgo (hSpans == 0 ? NULL : new SwitchIf (hspan, hSpans, from, next))
+       , hgo (hSpans == 0 ? NULL : new SwitchIf (hspan, hSpans, next))
        , lgo (NULL)
 {
        Span * bspan = new Span [nSpans];
        uint bSpans = unmap (bspan, span, nSpans, bm_state);
        lgo = bSpans == 0
                ? NULL
-               :  new SwitchIf (bspan, bSpans, from, next);
+               :  new SwitchIf (bspan, bSpans, next);
        delete bspan;
 }
 
@@ -355,8 +354,8 @@ void CpgotoTable::emit (OutputFile & o, uint ind)
        o << indent (--ind) << "};\n";
 }
 
-Cpgoto::Cpgoto (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const State * from, const State * next)
-       : hgo (hSpans == 0 ? NULL : new SwitchIf (hspan, hSpans, from, next))
+Cpgoto::Cpgoto (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const State * next)
+       : hgo (hSpans == 0 ? NULL : new SwitchIf (hspan, hSpans, next))
        , table (new CpgotoTable (span, nSpans))
 {}
 
@@ -402,7 +401,7 @@ Go::Go ()
        , info ()
 {}
 
-void Go::init (const State * from, const State * next)
+void Go::init (const State * from)
 {
        if (nSpans == 0)
        {
@@ -452,18 +451,18 @@ void Go::init (const State * from, const State * next)
        else if (gFlag && (dSpans >= cGotoThreshold))
        {
                type = CPGOTO;
-               info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, fromnext);
+               info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, from->next);
        }
        else if (bFlag && (nBitmaps > 0))
        {
                type = BITMAP;
-               info.bitmap = new Bitmap (span, nSpans, hspan, hSpans, bitmap, bitmap_state, fromnext);
+               info.bitmap = new Bitmap (span, nSpans, hspan, hSpans, bitmap, bitmap_state, from->next);
                bUsedYYBitmap = true;
        }
        else
        {
                type = SWITCH_IF;
-               info.switchif = new SwitchIf (span, nSpans, fromnext);
+               info.switchif = new SwitchIf (span, nSpans, from->next);
        }
 }
 
index 5753e870fb300e80c6cda50c7febb37675925353..f84e01d0156d4b32dea39dcf5a94bc455c2a7511 100644 (file)
--- a/re2c/go.h
+++ b/re2c/go.h
@@ -51,14 +51,14 @@ struct Binary
        Cond * cond;
        If * thn;
        If * els;
-       Binary (const Span * s, uint n, const State * from, const State * next);
+       Binary (const Span * s, uint n, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
 struct Linear
 {
        std::vector<std::pair<const Cond *, const State *> > branches;
-       Linear (const Span * s, uint n, const State * from, const State * next);
+       Linear (const Span * s, uint n, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
@@ -74,7 +74,7 @@ struct If
                Binary * binary;
                Linear * linear;
        } info;
-       If (type_t t, const Span * sp, uint nsp, const State * from, const State * next);
+       If (type_t t, const Span * sp, uint nsp, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
@@ -90,7 +90,7 @@ struct SwitchIf
                Cases * cases;
                If * ifs;
        } info;
-       SwitchIf (const Span * sp, uint nsp, const State * from, const State * next);
+       SwitchIf (const Span * sp, uint nsp, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
@@ -100,7 +100,7 @@ struct Bitmap
        const State * bitmap_state;
        SwitchIf * hgo;
        SwitchIf * lgo;
-       Bitmap (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const BitMap * bm, const State * bm_state, const State * from, const State * next);
+       Bitmap (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const BitMap * bm, const State * bm_state, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
@@ -115,7 +115,7 @@ struct Cpgoto
 {
        SwitchIf * hgo;
        CpgotoTable * table;
-       Cpgoto (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const State * from, const State * next);
+       Cpgoto (const Span * span, uint nSpans, const Span * hspan, uint hSpans, const State * next);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };
 
@@ -148,7 +148,7 @@ struct Go
        } info;
 
        Go ();
-       void init (const State * from, const State * next);
+       void init (const State * from);
        void emit (OutputFile & o, uint ind, bool & readCh);
 };