Avoid running the extradata parsing regex unnecessarily

This commit is contained in:
Thomas Goyne 2015-01-03 14:56:20 -08:00
parent bddf44ddde
commit d8bd9904d8
1 changed files with 16 additions and 14 deletions

View File

@ -123,6 +123,7 @@ void AssDialogue::Parse(std::string const& raw) {
std::string text{tkn.next_tok().begin(), str.end()}; std::string text{tkn.next_tok().begin(), str.end()};
if (text.size() > 1 && text[0] == '{' && text[1] == '=') {
static const boost::regex extradata_test("^\\{(=\\d+)+\\}"); static const boost::regex extradata_test("^\\{(=\\d+)+\\}");
boost::match_results<std::string::iterator> rematch; boost::match_results<std::string::iterator> rematch;
if (boost::regex_search(text.begin(), text.end(), rematch, extradata_test)) { if (boost::regex_search(text.begin(), text.end(), rematch, extradata_test)) {
@ -140,6 +141,7 @@ void AssDialogue::Parse(std::string const& raw) {
} }
ExtradataIds = ids; ExtradataIds = ids;
} }
}
Text = text; Text = text;
} }