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:
parent
1779a3b154
commit
682c4c9d2a
|
@ -2710,7 +2710,7 @@ bool ClientChannel::start(const String& target, const NamedList& params)
|
||||||
Message* m = message("call.route");
|
Message* m = message("call.route");
|
||||||
Message* s = message("chan.startup");
|
Message* s = message("chan.startup");
|
||||||
// Make sure we set the target's protocol if we have one
|
// 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;
|
String to = target;
|
||||||
const char* param = "callto";
|
const char* param = "callto";
|
||||||
if (!r.matches(target.safe())) {
|
if (!r.matches(target.safe())) {
|
||||||
|
|
|
@ -1600,7 +1600,7 @@ bool DefaultLogic::callContact(NamedList* params, Window* wnd)
|
||||||
call = !account.null();
|
call = !account.null();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Regexp r("^[a-z0-9]\\+/");
|
static const Regexp r("^[a-z0-9]\\+/");
|
||||||
if (!r.matches(target)) {
|
if (!r.matches(target)) {
|
||||||
// Incomplete target:
|
// Incomplete target:
|
||||||
// 1 registered account: call from it
|
// 1 registered account: call from it
|
||||||
|
|
|
@ -666,7 +666,7 @@ Message* SDPSession::buildChanRtp(SDPMedia* media, const char* addr, bool start,
|
||||||
if (m_secure) {
|
if (m_secure) {
|
||||||
if (media->remoteCrypto()) {
|
if (media->remoteCrypto()) {
|
||||||
String sdes = media->remoteCrypto();
|
String sdes = media->remoteCrypto();
|
||||||
Regexp r("^\\([0-9]\\+\\) \\+\\([^ ]\\+\\) \\+\\([^ ]\\+\\) *\\(.*\\)$");
|
static const Regexp r("^\\([0-9]\\+\\) \\+\\([^ ]\\+\\) \\+\\([^ ]\\+\\) *\\(.*\\)$");
|
||||||
if (sdes.matches(r)) {
|
if (sdes.matches(r)) {
|
||||||
m->addParam("secure",String::boolText(true));
|
m->addParam("secure",String::boolText(true));
|
||||||
m->addParam("crypto_tag",sdes.matchString(1));
|
m->addParam("crypto_tag",sdes.matchString(1));
|
||||||
|
|
|
@ -495,7 +495,7 @@ bool AlsaHandler::received(Message &msg)
|
||||||
String dest(msg.getValue("callto"));
|
String dest(msg.getValue("callto"));
|
||||||
if (dest.null())
|
if (dest.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^alsa/\\(.*\\)$");
|
static const Regexp r("^alsa/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
if (s_chan) {
|
if (s_chan) {
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
using namespace TelEngine;
|
using namespace TelEngine;
|
||||||
|
|
||||||
namespace { //anonymous
|
namespace { //anonymous
|
||||||
|
|
||||||
class CoreAudioSource : public ThreadedSource
|
class CoreAudioSource : public ThreadedSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -803,7 +803,7 @@ bool CoreAudioHandler::received(Message &msg)
|
||||||
String dest(msg.getValue("callto"));
|
String dest(msg.getValue("callto"));
|
||||||
if (dest.null())
|
if (dest.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^coreaudio/\\(.*\\)$");
|
static const Regexp r("^coreaudio/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
if (s_audioChan) {
|
if (s_audioChan) {
|
||||||
|
|
|
@ -485,7 +485,7 @@ bool OssHandler::received(Message &msg)
|
||||||
String dest(msg.getValue("callto"));
|
String dest(msg.getValue("callto"));
|
||||||
if (dest.null())
|
if (dest.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^oss/\\(.*\\)$");
|
static const Regexp r("^oss/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
if (s_chan) {
|
if (s_chan) {
|
||||||
|
|
|
@ -1265,7 +1265,7 @@ bool ExtModReceiver::processLine(const char* line)
|
||||||
id >> prio >> ":";
|
id >> prio >> ":";
|
||||||
String fname;
|
String fname;
|
||||||
String fvalue;
|
String fvalue;
|
||||||
Regexp r("^\\([^:]*\\):\\([^:]*\\):\\?\\(.*\\)");
|
static const Regexp r("^\\([^:]*\\):\\([^:]*\\):\\?\\(.*\\)");
|
||||||
if (id.matches(r)) {
|
if (id.matches(r)) {
|
||||||
// a filter is specified
|
// a filter is specified
|
||||||
fname = id.matchString(2);
|
fname = id.matchString(2);
|
||||||
|
@ -1506,7 +1506,7 @@ bool ExtModHandler::received(Message& msg)
|
||||||
String dest(msg.getValue("callto"));
|
String dest(msg.getValue("callto"));
|
||||||
if (dest.null())
|
if (dest.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^external/\\([^/]*\\)/\\([^ ]*\\)\\(.*\\)$");
|
static const Regexp r("^external/\\([^/]*\\)/\\([^ ]*\\)\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
CallEndpoint* ch = static_cast<CallEndpoint*>(msg.userData());
|
CallEndpoint* ch = static_cast<CallEndpoint*>(msg.userData());
|
||||||
|
|
|
@ -784,7 +784,7 @@ void FaxChan::updateInfo(t30_state_t* t30)
|
||||||
|
|
||||||
bool FaxDriver::msgExecute(Message& msg, String& dest)
|
bool FaxDriver::msgExecute(Message& msg, String& dest)
|
||||||
{
|
{
|
||||||
Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -750,7 +750,7 @@ FileDriver::~FileDriver()
|
||||||
// Execute/accept file transfer requests
|
// Execute/accept file transfer requests
|
||||||
bool FileDriver::msgExecute(Message& msg, String& dest)
|
bool FileDriver::msgExecute(Message& msg, String& dest)
|
||||||
{
|
{
|
||||||
Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -892,7 +892,7 @@ bool FileDriver::msgExecute(Message& msg, String& dest)
|
||||||
bool FileDriver::chanAttach(Message& msg)
|
bool FileDriver::chanAttach(Message& msg)
|
||||||
{
|
{
|
||||||
// Expect file/[send|receive]/filename
|
// Expect file/[send|receive]/filename
|
||||||
Regexp r("^filetransfer/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^filetransfer/\\([^/]*\\)/\\(.*\\)$");
|
||||||
|
|
||||||
String file(msg.getValue("source"));
|
String file(msg.getValue("source"));
|
||||||
// Direction
|
// Direction
|
||||||
|
|
|
@ -313,7 +313,7 @@ bool MOHHandler::received(Message &msg)
|
||||||
String dest(msg.getValue("callto"));
|
String dest(msg.getValue("callto"));
|
||||||
if (dest.null())
|
if (dest.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^moh/\\(.*\\)$");
|
static const Regexp r("^moh/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
String name = dest.matchString(1);
|
String name = dest.matchString(1);
|
||||||
|
@ -376,7 +376,7 @@ bool AttachHandler::received(Message &msg)
|
||||||
String src(msg.getValue("source"));
|
String src(msg.getValue("source"));
|
||||||
if (src.null())
|
if (src.null())
|
||||||
return false;
|
return false;
|
||||||
Regexp r("^moh/\\(.*\\)$");
|
static const Regexp r("^moh/\\(.*\\)$");
|
||||||
if (!src.matches(r))
|
if (!src.matches(r))
|
||||||
return false;
|
return false;
|
||||||
src = src.matchString(1);
|
src = src.matchString(1);
|
||||||
|
|
|
@ -838,7 +838,7 @@ bool Connection::autoComplete()
|
||||||
m.addParam("partword",partWord);
|
m.addParam("partword",partWord);
|
||||||
if ((partLine == "status") || (partLine == "debug") || (partLine == "drop"))
|
if ((partLine == "status") || (partLine == "debug") || (partLine == "drop"))
|
||||||
m.setParam("complete","channels");
|
m.setParam("complete","channels");
|
||||||
Regexp r("^debug [^ ]\\+$");
|
static const Regexp r("^debug [^ ]\\+$");
|
||||||
if (r.matches(partLine))
|
if (r.matches(partLine))
|
||||||
completeWords(m.retValue(),s_level,partWord);
|
completeWords(m.retValue(),s_level,partWord);
|
||||||
if (m_auth >= Admin)
|
if (m_auth >= Admin)
|
||||||
|
@ -1153,7 +1153,7 @@ bool Connection::processLine(const char *line)
|
||||||
Message m("chan.control");
|
Message m("chan.control");
|
||||||
m.addParam("targetid",id);
|
m.addParam("targetid",id);
|
||||||
m.addParam("component",id);
|
m.addParam("component",id);
|
||||||
Regexp r("^\\(.* \\)\\?\\([^= ]\\+\\)=\\([^=]*\\)$");
|
static const Regexp r("^\\(.* \\)\\?\\([^= ]\\+\\)=\\([^=]*\\)$");
|
||||||
while (ctrl) {
|
while (ctrl) {
|
||||||
if (!ctrl.matches(r)) {
|
if (!ctrl.matches(r)) {
|
||||||
m.setParam("operation",ctrl);
|
m.setParam("operation",ctrl);
|
||||||
|
|
|
@ -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
|
// Increment the number at the end of a name by an offset
|
||||||
static bool tailIncrement(String& name, unsigned int offs)
|
static bool tailIncrement(String& name, unsigned int offs)
|
||||||
{
|
{
|
||||||
Regexp r("\\([0-9]\\+\\)@");
|
static const Regexp r("\\([0-9]\\+\\)@");
|
||||||
if (name.matches(r)) {
|
if (name.matches(r)) {
|
||||||
int pos = name.matchOffset(1);
|
int pos = name.matchOffset(1);
|
||||||
unsigned int len = name.matchLength(1);
|
unsigned int len = name.matchLength(1);
|
||||||
|
@ -1026,16 +1026,16 @@ bool MGCPSpan::matchEndpoint(const MGCPEndpointId& ep)
|
||||||
if (findCircuit(ep.id()))
|
if (findCircuit(ep.id()))
|
||||||
return true;
|
return true;
|
||||||
// check for wildcards like */*/*
|
// check for wildcards like */*/*
|
||||||
static Regexp s_termsAll("^\\*[/*]\\+\\*$");
|
static const Regexp s_termsAll("^\\*[/*]\\+\\*$");
|
||||||
if (s_termsAll.matches(ep.user()))
|
if (s_termsAll.matches(ep.user()))
|
||||||
return true;
|
return true;
|
||||||
String tmp = ep.user();
|
String tmp = ep.user();
|
||||||
// check for prefix/*/*
|
// 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))
|
if (tmp.matches(s_finalAll) && m_epId.user().startsWith(tmp.matchString(1),false,true))
|
||||||
return true;
|
return true;
|
||||||
// check for prefix[min-max]
|
// 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)))
|
if (!(tmp.matches(s_finalRange) && m_epId.user().startsWith(tmp.matchString(1),false,true)))
|
||||||
return false;
|
return false;
|
||||||
int idx = m_epId.user().substr(tmp.matchLength(1)).toInteger(-1,10);
|
int idx = m_epId.user().substr(tmp.matchLength(1)).toInteger(-1,10);
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ void RadiusClient::addAttributes(NamedList& params, NamedList* list)
|
||||||
continue;
|
continue;
|
||||||
String val = *s;
|
String val = *s;
|
||||||
params.replaceParams(val);
|
params.replaceParams(val);
|
||||||
Regexp r("^\\([0-9]\\+\\):\\(.*\\)");
|
static const Regexp r("^\\([0-9]\\+\\):\\(.*\\)");
|
||||||
if (key.matches(r)) {
|
if (key.matches(r)) {
|
||||||
int subType = key.matchString(1).toInteger(-1);
|
int subType = key.matchString(1).toInteger(-1);
|
||||||
if ((subType >= 0) && (subType <= 255)) {
|
if ((subType >= 0) && (subType <= 255)) {
|
||||||
|
|
|
@ -801,7 +801,7 @@ bool AttachHandler::received(Message &msg)
|
||||||
if (src.null())
|
if (src.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (src.matches(r)) {
|
if (src.matches(r)) {
|
||||||
if (src.matchString(1) == "play") {
|
if (src.matchString(1) == "play") {
|
||||||
src = src.matchString(2);
|
src = src.matchString(2);
|
||||||
|
@ -821,7 +821,7 @@ bool AttachHandler::received(Message &msg)
|
||||||
if (cons.null())
|
if (cons.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (cons.matches(r)) {
|
if (cons.matches(r)) {
|
||||||
if (cons.matchString(1) == "record") {
|
if (cons.matchString(1) == "record") {
|
||||||
cons = cons.matchString(2);
|
cons = cons.matchString(2);
|
||||||
|
@ -841,7 +841,7 @@ bool AttachHandler::received(Message &msg)
|
||||||
if (ovr.null())
|
if (ovr.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (ovr.matches(r)) {
|
if (ovr.matches(r)) {
|
||||||
if (ovr.matchString(1) == "play") {
|
if (ovr.matchString(1) == "play") {
|
||||||
ovr = ovr.matchString(2);
|
ovr = ovr.matchString(2);
|
||||||
|
@ -861,7 +861,7 @@ bool AttachHandler::received(Message &msg)
|
||||||
if (repl.null())
|
if (repl.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (repl.matches(r)) {
|
if (repl.matches(r)) {
|
||||||
if (repl.matchString(1) == "play") {
|
if (repl.matchString(1) == "play") {
|
||||||
repl = repl.matchString(2);
|
repl = repl.matchString(2);
|
||||||
|
@ -970,7 +970,7 @@ bool RecordHandler::received(Message &msg)
|
||||||
if (c1.null())
|
if (c1.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (c1.matches(r)) {
|
if (c1.matches(r)) {
|
||||||
if (c1.matchString(1) == "record") {
|
if (c1.matchString(1) == "record") {
|
||||||
c1 = c1.matchString(2);
|
c1 = c1.matchString(2);
|
||||||
|
@ -990,7 +990,7 @@ bool RecordHandler::received(Message &msg)
|
||||||
if (c2.null())
|
if (c2.null())
|
||||||
more--;
|
more--;
|
||||||
else {
|
else {
|
||||||
Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^wave/\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (c2.matches(r)) {
|
if (c2.matches(r)) {
|
||||||
if (c2.matchString(1) == "record") {
|
if (c2.matchString(1) == "record") {
|
||||||
c2 = c2.matchString(2);
|
c2 = c2.matchString(2);
|
||||||
|
@ -1046,7 +1046,7 @@ bool RecordHandler::received(Message &msg)
|
||||||
|
|
||||||
bool WaveFileDriver::msgExecute(Message& msg, String& dest)
|
bool WaveFileDriver::msgExecute(Message& msg, String& dest)
|
||||||
{
|
{
|
||||||
Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
static const Regexp r("^\\([^/]*\\)/\\(.*\\)$");
|
||||||
if (!dest.matches(r))
|
if (!dest.matches(r))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -1811,7 +1811,7 @@ void IAXURI::parse()
|
||||||
if (m_parsed)
|
if (m_parsed)
|
||||||
return;
|
return;
|
||||||
String tmp(*this), _port;
|
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))
|
if (tmp.matches(r))
|
||||||
{
|
{
|
||||||
m_username = tmp.matchString(2);
|
m_username = tmp.matchString(2);
|
||||||
|
|
Loading…
Reference in New Issue