From 682c4c9d2a8a5768c1516a4163ea1862b86efe5a Mon Sep 17 00:00:00 2001 From: paulc Date: Thu, 17 Jun 2010 11:38:46 +0000 Subject: [PATCH] Use static const Regexps wherever possible to speed up code. git-svn-id: http://yate.null.ro/svn/yate/trunk@3391 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/Client.cpp | 2 +- engine/ClientLogic.cpp | 2 +- libs/ysdp/session.cpp | 2 +- modules/client/alsachan.cpp | 2 +- modules/client/coreaudio.cpp | 4 ++-- modules/client/osschan.cpp | 2 +- modules/extmodule.cpp | 4 ++-- modules/faxchan.cpp | 2 +- modules/filetransfer.cpp | 4 ++-- modules/moh.cpp | 4 ++-- modules/rmanager.cpp | 4 ++-- modules/server/mgcpca.cpp | 8 ++++---- modules/server/yradius.cpp | 2 +- modules/wavefile.cpp | 14 +++++++------- modules/yiaxchan.cpp | 2 +- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/engine/Client.cpp b/engine/Client.cpp index b0ad61f8..92b6fccc 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -2710,7 +2710,7 @@ bool ClientChannel::start(const String& target, const NamedList& params) Message* m = message("call.route"); Message* s = message("chan.startup"); // Make sure we set the target's protocol if we have one - Regexp r("^[a-z0-9]\\+/"); + static const Regexp r("^[a-z0-9]\\+/"); String to = target; const char* param = "callto"; if (!r.matches(target.safe())) { diff --git a/engine/ClientLogic.cpp b/engine/ClientLogic.cpp index 8bfdd64f..7973e228 100644 --- a/engine/ClientLogic.cpp +++ b/engine/ClientLogic.cpp @@ -1600,7 +1600,7 @@ bool DefaultLogic::callContact(NamedList* params, Window* wnd) call = !account.null(); } else { - Regexp r("^[a-z0-9]\\+/"); + static const Regexp r("^[a-z0-9]\\+/"); if (!r.matches(target)) { // Incomplete target: // 1 registered account: call from it diff --git a/libs/ysdp/session.cpp b/libs/ysdp/session.cpp index 5e7aecff..ca5f7968 100644 --- a/libs/ysdp/session.cpp +++ b/libs/ysdp/session.cpp @@ -666,7 +666,7 @@ Message* SDPSession::buildChanRtp(SDPMedia* media, const char* addr, bool start, if (m_secure) { if (media->remoteCrypto()) { String sdes = media->remoteCrypto(); - Regexp r("^\\([0-9]\\+\\) \\+\\([^ ]\\+\\) \\+\\([^ ]\\+\\) *\\(.*\\)$"); + static const Regexp r("^\\([0-9]\\+\\) \\+\\([^ ]\\+\\) \\+\\([^ ]\\+\\) *\\(.*\\)$"); if (sdes.matches(r)) { m->addParam("secure",String::boolText(true)); m->addParam("crypto_tag",sdes.matchString(1)); diff --git a/modules/client/alsachan.cpp b/modules/client/alsachan.cpp index 3155c03b..bf0a719a 100644 --- a/modules/client/alsachan.cpp +++ b/modules/client/alsachan.cpp @@ -495,7 +495,7 @@ bool AlsaHandler::received(Message &msg) String dest(msg.getValue("callto")); if (dest.null()) return false; - Regexp r("^alsa/\\(.*\\)$"); + static const Regexp r("^alsa/\\(.*\\)$"); if (!dest.matches(r)) return false; if (s_chan) { diff --git a/modules/client/coreaudio.cpp b/modules/client/coreaudio.cpp index b2b893a3..007985b6 100644 --- a/modules/client/coreaudio.cpp +++ b/modules/client/coreaudio.cpp @@ -34,7 +34,7 @@ using namespace TelEngine; namespace { //anonymous - + class CoreAudioSource : public ThreadedSource { public: @@ -803,7 +803,7 @@ bool CoreAudioHandler::received(Message &msg) String dest(msg.getValue("callto")); if (dest.null()) return false; - Regexp r("^coreaudio/\\(.*\\)$"); + static const Regexp r("^coreaudio/\\(.*\\)$"); if (!dest.matches(r)) return false; if (s_audioChan) { diff --git a/modules/client/osschan.cpp b/modules/client/osschan.cpp index 7d7aaf60..7b4ec087 100644 --- a/modules/client/osschan.cpp +++ b/modules/client/osschan.cpp @@ -485,7 +485,7 @@ bool OssHandler::received(Message &msg) String dest(msg.getValue("callto")); if (dest.null()) return false; - Regexp r("^oss/\\(.*\\)$"); + static const Regexp r("^oss/\\(.*\\)$"); if (!dest.matches(r)) return false; if (s_chan) { diff --git a/modules/extmodule.cpp b/modules/extmodule.cpp index c35a183b..b5fa0f4b 100644 --- a/modules/extmodule.cpp +++ b/modules/extmodule.cpp @@ -1265,7 +1265,7 @@ bool ExtModReceiver::processLine(const char* line) id >> prio >> ":"; String fname; String fvalue; - Regexp r("^\\([^:]*\\):\\([^:]*\\):\\?\\(.*\\)"); + static const Regexp r("^\\([^:]*\\):\\([^:]*\\):\\?\\(.*\\)"); if (id.matches(r)) { // a filter is specified fname = id.matchString(2); @@ -1506,7 +1506,7 @@ bool ExtModHandler::received(Message& msg) String dest(msg.getValue("callto")); if (dest.null()) return false; - Regexp r("^external/\\([^/]*\\)/\\([^ ]*\\)\\(.*\\)$"); + static const Regexp r("^external/\\([^/]*\\)/\\([^ ]*\\)\\(.*\\)$"); if (!dest.matches(r)) return false; CallEndpoint* ch = static_cast(msg.userData()); diff --git a/modules/faxchan.cpp b/modules/faxchan.cpp index 4d8d384d..ef0b269d 100644 --- a/modules/faxchan.cpp +++ b/modules/faxchan.cpp @@ -784,7 +784,7 @@ void FaxChan::updateInfo(t30_state_t* t30) bool FaxDriver::msgExecute(Message& msg, String& dest) { - Regexp r("^\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^\\([^/]*\\)/\\(.*\\)$"); if (!dest.matches(r)) return false; diff --git a/modules/filetransfer.cpp b/modules/filetransfer.cpp index cb034989..85272436 100644 --- a/modules/filetransfer.cpp +++ b/modules/filetransfer.cpp @@ -750,7 +750,7 @@ FileDriver::~FileDriver() // Execute/accept file transfer requests bool FileDriver::msgExecute(Message& msg, String& dest) { - Regexp r("^\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^\\([^/]*\\)/\\(.*\\)$"); if (!dest.matches(r)) return false; @@ -892,7 +892,7 @@ bool FileDriver::msgExecute(Message& msg, String& dest) bool FileDriver::chanAttach(Message& msg) { // Expect file/[send|receive]/filename - Regexp r("^filetransfer/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^filetransfer/\\([^/]*\\)/\\(.*\\)$"); String file(msg.getValue("source")); // Direction diff --git a/modules/moh.cpp b/modules/moh.cpp index 689366dc..a87f8ac3 100644 --- a/modules/moh.cpp +++ b/modules/moh.cpp @@ -313,7 +313,7 @@ bool MOHHandler::received(Message &msg) String dest(msg.getValue("callto")); if (dest.null()) return false; - Regexp r("^moh/\\(.*\\)$"); + static const Regexp r("^moh/\\(.*\\)$"); if (!dest.matches(r)) return false; String name = dest.matchString(1); @@ -376,7 +376,7 @@ bool AttachHandler::received(Message &msg) String src(msg.getValue("source")); if (src.null()) return false; - Regexp r("^moh/\\(.*\\)$"); + static const Regexp r("^moh/\\(.*\\)$"); if (!src.matches(r)) return false; src = src.matchString(1); diff --git a/modules/rmanager.cpp b/modules/rmanager.cpp index abc4b59c..8d3e32db 100644 --- a/modules/rmanager.cpp +++ b/modules/rmanager.cpp @@ -838,7 +838,7 @@ bool Connection::autoComplete() m.addParam("partword",partWord); if ((partLine == "status") || (partLine == "debug") || (partLine == "drop")) m.setParam("complete","channels"); - Regexp r("^debug [^ ]\\+$"); + static const Regexp r("^debug [^ ]\\+$"); if (r.matches(partLine)) completeWords(m.retValue(),s_level,partWord); if (m_auth >= Admin) @@ -1153,7 +1153,7 @@ bool Connection::processLine(const char *line) Message m("chan.control"); m.addParam("targetid",id); m.addParam("component",id); - Regexp r("^\\(.* \\)\\?\\([^= ]\\+\\)=\\([^=]*\\)$"); + static const Regexp r("^\\(.* \\)\\?\\([^= ]\\+\\)=\\([^=]*\\)$"); while (ctrl) { if (!ctrl.matches(r)) { m.setParam("operation",ctrl); diff --git a/modules/server/mgcpca.cpp b/modules/server/mgcpca.cpp index 463882da..e65fb410 100644 --- a/modules/server/mgcpca.cpp +++ b/modules/server/mgcpca.cpp @@ -342,7 +342,7 @@ static bool copyRename(NamedList& dest, const char* dname, const NamedList& src, // Increment the number at the end of a name by an offset static bool tailIncrement(String& name, unsigned int offs) { - Regexp r("\\([0-9]\\+\\)@"); + static const Regexp r("\\([0-9]\\+\\)@"); if (name.matches(r)) { int pos = name.matchOffset(1); unsigned int len = name.matchLength(1); @@ -1026,16 +1026,16 @@ bool MGCPSpan::matchEndpoint(const MGCPEndpointId& ep) if (findCircuit(ep.id())) return true; // check for wildcards like */*/* - static Regexp s_termsAll("^\\*[/*]\\+\\*$"); + static const Regexp s_termsAll("^\\*[/*]\\+\\*$"); if (s_termsAll.matches(ep.user())) return true; String tmp = ep.user(); // check for prefix/*/* - static Regexp s_finalAll("^\\([^*]\\+/\\)[/*]\\+$"); + static const Regexp s_finalAll("^\\([^*]\\+/\\)[/*]\\+$"); if (tmp.matches(s_finalAll) && m_epId.user().startsWith(tmp.matchString(1),false,true)) return true; // check for prefix[min-max] - static Regexp s_finalRange("^\\(.*\\)\\[\\([0-9]\\+\\)-\\([0-9]\\+\\)\\]$"); + static const Regexp s_finalRange("^\\(.*\\)\\[\\([0-9]\\+\\)-\\([0-9]\\+\\)\\]$"); if (!(tmp.matches(s_finalRange) && m_epId.user().startsWith(tmp.matchString(1),false,true))) return false; int idx = m_epId.user().substr(tmp.matchLength(1)).toInteger(-1,10); diff --git a/modules/server/yradius.cpp b/modules/server/yradius.cpp index ee14db69..3d42f3b2 100644 --- a/modules/server/yradius.cpp +++ b/modules/server/yradius.cpp @@ -1168,7 +1168,7 @@ void RadiusClient::addAttributes(NamedList& params, NamedList* list) continue; String val = *s; params.replaceParams(val); - Regexp r("^\\([0-9]\\+\\):\\(.*\\)"); + static const Regexp r("^\\([0-9]\\+\\):\\(.*\\)"); if (key.matches(r)) { int subType = key.matchString(1).toInteger(-1); if ((subType >= 0) && (subType <= 255)) { diff --git a/modules/wavefile.cpp b/modules/wavefile.cpp index 332ee5a3..2284e261 100644 --- a/modules/wavefile.cpp +++ b/modules/wavefile.cpp @@ -801,7 +801,7 @@ bool AttachHandler::received(Message &msg) if (src.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (src.matches(r)) { if (src.matchString(1) == "play") { src = src.matchString(2); @@ -821,7 +821,7 @@ bool AttachHandler::received(Message &msg) if (cons.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (cons.matches(r)) { if (cons.matchString(1) == "record") { cons = cons.matchString(2); @@ -841,7 +841,7 @@ bool AttachHandler::received(Message &msg) if (ovr.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (ovr.matches(r)) { if (ovr.matchString(1) == "play") { ovr = ovr.matchString(2); @@ -861,7 +861,7 @@ bool AttachHandler::received(Message &msg) if (repl.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (repl.matches(r)) { if (repl.matchString(1) == "play") { repl = repl.matchString(2); @@ -970,7 +970,7 @@ bool RecordHandler::received(Message &msg) if (c1.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (c1.matches(r)) { if (c1.matchString(1) == "record") { c1 = c1.matchString(2); @@ -990,7 +990,7 @@ bool RecordHandler::received(Message &msg) if (c2.null()) more--; else { - Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$"); if (c2.matches(r)) { if (c2.matchString(1) == "record") { c2 = c2.matchString(2); @@ -1046,7 +1046,7 @@ bool RecordHandler::received(Message &msg) bool WaveFileDriver::msgExecute(Message& msg, String& dest) { - Regexp r("^\\([^/]*\\)/\\(.*\\)$"); + static const Regexp r("^\\([^/]*\\)/\\(.*\\)$"); if (!dest.matches(r)) return false; diff --git a/modules/yiaxchan.cpp b/modules/yiaxchan.cpp index 7bc9fba5..6049020b 100644 --- a/modules/yiaxchan.cpp +++ b/modules/yiaxchan.cpp @@ -1811,7 +1811,7 @@ void IAXURI::parse() if (m_parsed) return; String tmp(*this), _port; - Regexp r("^\\([Ii][Aa][Xx]2\\+:\\)\\?\\([^[:space:][:cntrl:]@]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?\\(/[[:alnum:]]*\\)\\?\\([@?][^@?:/]*\\)\\?$"); + static const Regexp r("^\\([Ii][Aa][Xx]2\\+:\\)\\?\\([^[:space:][:cntrl:]@]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?\\(/[[:alnum:]]*\\)\\?\\([@?][^@?:/]*\\)\\?$"); if (tmp.matches(r)) { m_username = tmp.matchString(2);