Skip to content
Snippets Groups Projects
Commit 6cc9b545 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

speedup

parent 34b82493
No related branches found
No related tags found
No related merge requests found
...@@ -223,7 +223,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>& ...@@ -223,7 +223,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>&
   
for(const label::Label& state : oldStates) { for(const label::Label& state : oldStates) {
for(const auto& transition : d.getLocalTransitions()) { for(const auto& transition : d.getLocalTransitions()) {
if(!transition.second.count(automaton::State(state))) continue; if(transition.second.begin()->getName() != state) continue;
   
if(!states.count(transition.first.first.getName())) { if(!states.count(transition.first.first.getName())) {
states.insert(transition.first.first.getName()); states.insert(transition.first.first.getName());
...@@ -232,7 +232,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>& ...@@ -232,7 +232,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>&
} }
   
for(const auto& transition : d.getReturnTransitions()) { for(const auto& transition : d.getReturnTransitions()) {
if(!transition.second.count(automaton::State(state))) continue; if(transition.second.begin()->getName() != state) continue;
   
const alphabet::Symbol& popSymbol = std::get<2>(transition.first); const alphabet::Symbol& popSymbol = std::get<2>(transition.first);
if(popSymbol == d.getBottomOfTheStackSymbol()) continue; if(popSymbol == d.getBottomOfTheStackSymbol()) continue;
...@@ -250,7 +250,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>& ...@@ -250,7 +250,7 @@ void localClosure(std::set<label::Label>& states, const std::set<label::Label>&
localClosure(states, newStates, d); localClosure(states, newStates, d);
} }
   
std::pair<label::Label, alphabet::Symbol>* existsDirtyStateSymbol(const automaton::VisiblyPushdownNPDA& d) { std::pair<automaton::State, alphabet::Symbol>* existsDirtyStateSymbol(const automaton::VisiblyPushdownNPDA& d) {
for(const automaton::State& state : d.getStates()) { for(const automaton::State& state : d.getStates()) {
const label::Label& stateLabel = state.getName(); const label::Label& stateLabel = state.getName();
   
...@@ -267,7 +267,7 @@ std::pair<label::Label, alphabet::Symbol>* existsDirtyStateSymbol(const automato ...@@ -267,7 +267,7 @@ std::pair<label::Label, alphabet::Symbol>* existsDirtyStateSymbol(const automato
} }
} }
   
if(d.getInitialStates().count(localState)) { if(d.getInitialStates().begin()->getName() == localState) {
topSymbols.insert(d.getBottomOfTheStackSymbol()); topSymbols.insert(d.getBottomOfTheStackSymbol());
} }
} }
...@@ -278,7 +278,7 @@ std::pair<label::Label, alphabet::Symbol>* existsDirtyStateSymbol(const automato ...@@ -278,7 +278,7 @@ std::pair<label::Label, alphabet::Symbol>* existsDirtyStateSymbol(const automato
topSymbols.erase(std::get<2>(transition.first)); topSymbols.erase(std::get<2>(transition.first));
} }
   
if(!topSymbols.empty()) return new std::pair<label::Label, alphabet::Symbol>(stateLabel, *topSymbols.begin()); if(!topSymbols.empty()) return new std::pair<automaton::State, alphabet::Symbol>(automaton::State(stateLabel), *topSymbols.begin());
} }
return NULL; return NULL;
} }
...@@ -302,7 +302,7 @@ automaton::VisiblyPushdownNPDA VPADeterminizer::determinize(const automaton::Vis ...@@ -302,7 +302,7 @@ automaton::VisiblyPushdownNPDA VPADeterminizer::determinize(const automaton::Vis
d.addInitialState(automaton::State(initialLabel)); d.addInitialState(automaton::State(initialLabel));
for(;;) { for(;;) {
std::pair<label::Label, alphabet::Symbol>* stateSymbol = existsDirtyStateSymbol(d); std::pair<automaton::State, alphabet::Symbol>* stateSymbol = existsDirtyStateSymbol(d);
const automaton::State* state = existsDirtyState(d); const automaton::State* state = existsDirtyState(d);
if(stateSymbol != NULL) { if(stateSymbol != NULL) {
for(const alphabet::Symbol& symbol : n.getReturnInputAlphabet()) { for(const alphabet::Symbol& symbol : n.getReturnInputAlphabet()) {
......
...@@ -22,11 +22,11 @@ class State { ...@@ -22,11 +22,11 @@ class State {
private: private:
label::Label name; label::Label name;
public: public:
State(const label::Label& name); explicit State(const label::Label& name);
State(label::Label&& name); explicit State(label::Label&& name);
State(int number); explicit State(int number);
State(char character); explicit State(char character);
State(const std::string& name); explicit State(const std::string& name);
   
const label::Label& getName() const; const label::Label& getName() const;
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment