Skip to content

Commit

Permalink
perf: some adjustment then fix time left. 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Apr 26, 2023
1 parent 306e267 commit 56ed216
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
56 changes: 28 additions & 28 deletions src/EngineLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,35 +152,35 @@ vector<int> EngineLoader::split(const string &str, char sep)
return tokens;
}

string EngineLoader::format_string(string& res) {
//delete 0x0d,0x0a
res.erase(remove(res.begin(), res.end(), '\r'), res.end());
res.erase(remove(res.begin(), res.end(), '\n'), res.end());
return res;
}
// string EngineLoader::format_string(string& res) {
// //delete 0x0d,0x0a
// res.erase(remove(res.begin(), res.end(), '\r'), res.end());
// res.erase(remove(res.begin(), res.end(), '\n'), res.end());
// return res;
// }

const string EngineLoader::response_filter(const string &str_res)
{
string s_get, s_tmp;
s_get.clear();
s_tmp.clear();
s_tmp = str_res;
if (s_tmp.empty())
return "";
if (s_tmp.find_first_of("OK") == 0)
s_get = this->format_string(s_tmp);
else if (s_tmp.find_first_of("ERROR ") == 0)
s_get = this->format_string(s_tmp);
else if (s_tmp.find_first_of("UNKNOWN ") == 0)
s_get = this->format_string(s_tmp);
else if (s_tmp.find_first_of("MESSAGE ") == 0)
s_get = this->format_string(s_tmp);
else if (s_tmp.find_first_of("DEBUG ") == 0)
s_get = this->format_string(s_tmp);
else if ((s_tmp.find_first_of(',') == 2 || s_tmp.find_first_of(',') == 1) && this->split(s_tmp, ',').size() == 2)
s_get = this->format_string(s_tmp);
return s_get;
}
// const string EngineLoader::response_filter(const string &str_res)
// {
// string s_get, s_tmp;
// s_get.clear();
// s_tmp.clear();
// s_tmp = str_res;
// if (s_tmp.empty())
// return "";
// if (s_tmp.find_first_of("OK") == 0)
// s_get = this->format_string(s_tmp);
// else if (s_tmp.find_first_of("ERROR ") == 0)
// s_get = this->format_string(s_tmp);
// else if (s_tmp.find_first_of("UNKNOWN ") == 0)
// s_get = this->format_string(s_tmp);
// else if (s_tmp.find_first_of("MESSAGE ") == 0)
// s_get = this->format_string(s_tmp);
// else if (s_tmp.find_first_of("DEBUG ") == 0)
// s_get = this->format_string(s_tmp);
// else if ((s_tmp.find_first_of(',') == 2 || s_tmp.find_first_of(',') == 1) && this->split(s_tmp, ',').size() == 2)
// s_get = this->format_string(s_tmp);
// return s_get;
// }

void EngineLoader::response_parse(const string &str)
{
Expand Down
4 changes: 2 additions & 2 deletions src/EngineLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class EngineLoader : public QObject

vector<string> split(const string &str, const string &pattern);
vector<int> split(const string &str, char sep);
string format_string(string &str);
const string response_filter(const string &sResp);
// string format_string(string &str);
// const string response_filter(const string &sResp);
void response_parse(const string &sResp);

signals:
Expand Down
2 changes: 2 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ void MainWindow::OnActionStart()
this->m_T1->stop();
if (nullptr != this->m_T2)
this->m_T2->stop();
this->m_time_left_p1 = this->m_timeout_match;
this->m_time_left_p2 = this->m_timeout_match;

this->m_manager->m_p1->m_color = STONECOLOR::BLACK;
this->m_manager->m_p2->m_color = STONECOLOR::WHITE;
Expand Down

0 comments on commit 56ed216

Please sign in to comment.