[asterisk-commits] file: branch file/res_sorcery_astdb r384241 - /team/file/res_sorcery_astdb/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 28 06:52:50 CDT 2013
Author: file
Date: Thu Mar 28 06:52:41 2013
New Revision: 384241
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384241
Log:
Improve performance for the current regex use case using pattern matching.
Modified:
team/file/res_sorcery_astdb/res/res_sorcery_astdb.c
Modified: team/file/res_sorcery_astdb/res/res_sorcery_astdb.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_astdb/res/res_sorcery_astdb.c?view=diff&rev=384241&r1=384240&r2=384241
==============================================================================
--- team/file/res_sorcery_astdb/res/res_sorcery_astdb.c (original)
+++ team/file/res_sorcery_astdb/res/res_sorcery_astdb.c Thu Mar 28 06:52:41 2013
@@ -219,14 +219,20 @@
static void sorcery_astdb_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
{
const char *prefix = data;
- char family[strlen(prefix) + strlen(type) + 2];
+ char family[strlen(prefix) + strlen(type) + 2], tree[strlen(regex) + 1];
RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree);
regex_t expression;
struct ast_db_entry *entry;
snprintf(family, sizeof(family), "%s/%s", prefix, type);
- if (!(entries = ast_db_gettree(family, NULL)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
+ if (regex[0] == '^') {
+ snprintf(tree, sizeof(tree), "%s%%", regex + 1);
+ } else {
+ tree[0] = '\0';
+ }
+
+ if (!(entries = ast_db_gettree(family, tree)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
return;
}
More information about the asterisk-commits
mailing list