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
This commit is contained in:
paulc 2010-06-17 11:38:46 +00:00
parent 1779a3b154
commit 682c4c9d2a
15 changed files with 29 additions and 29 deletions

View File

@ -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())) {

View File

@ -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

View File

@ -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));

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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<CallEndpoint*>(msg.userData());

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)) {

View File

@ -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;

View File

@ -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);