summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-05-03 09:10:08 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-05-03 09:10:08 +0100
commit93184e732f824524ec4ba144488c3b2a62387ab3 (patch)
tree17c0b0be95443a83c10366ccef91d884d57150aa
parentAdd a dependency scanner/extracter (diff)
downloadgentoobrowse-api-93184e732f824524ec4ba144488c3b2a62387ab3.tar.bz2
gentoobrowse-api-93184e732f824524ec4ba144488c3b2a62387ab3.tar.xz
gentoobrowse-api-93184e732f824524ec4ba144488c3b2a62387ab3.zip
Precompile regexen for dependencies
-rw-r--r--gentoobrowse-api/service/depend.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/gentoobrowse-api/service/depend.cpp b/gentoobrowse-api/service/depend.cpp
index f93787e..fad6b64 100644
--- a/gentoobrowse-api/service/depend.cpp
+++ b/gentoobrowse-api/service/depend.cpp
@@ -1,18 +1,18 @@
#include "depend.h"
#include <boost/algorithm/string/split.hpp>
-const Glib::ustring WhenUse_Begin("\\s*(!?[[:alnum:]-_]+)\\?\\s*\\(\\s*");
-const Glib::ustring WhenUse_End("\\s*\\)\\s*");
-const Glib::ustring Or_Begin("\\s*\\|\\|\\s*\\(\\s*");
-const Glib::ustring Or_Group("\\s*\\(\\s*");
-const Glib::ustring Or_End("\\s*\\)\\s*");
-const Glib::ustring AtomSpec("\\s*"
+Gentoo::Utils::Lexer::PatternPtr WhenUse_Begin(Gentoo::Utils::Lexer::regex("\\s*(!?[[:alnum:]-_]+)\\?\\s*\\(\\s*", G_REGEX_OPTIMIZE));
+Gentoo::Utils::Lexer::PatternPtr WhenUse_End(Gentoo::Utils::Lexer::regex("\\s*\\)\\s*", G_REGEX_OPTIMIZE));
+Gentoo::Utils::Lexer::PatternPtr Or_Begin(Gentoo::Utils::Lexer::regex("\\s*\\|\\|\\s*\\(\\s*", G_REGEX_OPTIMIZE));
+Gentoo::Utils::Lexer::PatternPtr Or_Group(Gentoo::Utils::Lexer::regex("\\s*\\(\\s*", G_REGEX_OPTIMIZE));
+Gentoo::Utils::Lexer::PatternPtr Or_End(Gentoo::Utils::Lexer::regex("\\s*\\)\\s*", G_REGEX_OPTIMIZE));
+Gentoo::Utils::Lexer::PatternPtr AtomSpec(Gentoo::Utils::Lexer::regex("\\s*"
"([[:punct:]]+)?" // op
"([[:alnum:]-]+)\\/" // cat
"(((-?[[:alpha:]]+[[:digit:]]+)|[[:alpha:]_+]|(-[[:alpha:]]))+)" // package
"(-([0-9][.0-9]*[[:alpha:]]?\\*?(_(alpha|beta|pre|rc|p))?[[:digit:]]*(-r[[:digit:]]+)?))?" // version
"(:([^/ []+(\\/[^ []+)?))?" // slot
- "(\\[([^]]+)\\])?\\s*"); // use
+ "(\\[([^]]+)\\])?\\s*", G_REGEX_OPTIMIZE)); // use
const std::string InWhen("InWhen");
const std::string InOr("InOr");
@@ -40,29 +40,29 @@ namespace Portage {
Depend::Depend()
{
// use? (
- rules.push_back({ { InitialState, InWhen, InOr }, regex(WhenUse_Begin), [this](auto es) {
+ rules.push_back({ { InitialState, InWhen, InOr }, WhenUse_Begin, [this](auto es) {
es->pushState(InWhen);
when.push_back(*es->pattern->match(1));
} });
// )
- rules.push_back({ { InWhen }, regex(WhenUse_End), [this](auto es) {
+ rules.push_back({ { InWhen }, WhenUse_End, [this](auto es) {
es->popState();
when.pop_back();
} });
// || (
- rules.push_back({ { InitialState, InWhen, InOr }, regex(Or_Begin), [this](auto es) {
+ rules.push_back({ { InitialState, InWhen, InOr }, Or_Begin, [this](auto es) {
es->pushState(InOr);
} });
// || (
- rules.push_back({ { InOr }, regex(Or_Group), [this](auto es) {
+ rules.push_back({ { InOr }, Or_Group, [this](auto es) {
es->pushState(InOr);
} });
// )
- rules.push_back({ { InOr }, regex(Or_End), [this](auto es) {
+ rules.push_back({ { InOr }, Or_End, [this](auto es) {
es->popState();
} });
// [op]some-cat/package[-version][:slot][uses]
- rules.push_back({ { InitialState, InWhen, InOr }, regex(AtomSpec), [this](auto es) {
+ rules.push_back({ { InitialState, InWhen, InOr }, AtomSpec, [this](auto es) {
ds.push_back(new Gentoo::Dependency(
when,
iuo<std::string>(es->pattern->match(1)), // op