Improve config parsing performance (bug #5448)
authorMark Spencer <markster@digium.com>
Mon, 17 Oct 2005 03:53:27 +0000 (03:53 +0000)
committerMark Spencer <markster@digium.com>
Mon, 17 Oct 2005 03:53:27 +0000 (03:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6804 65c4cc65-6c06-0410-ace0-fbb531ad65f3

config.c

index 138e28f..846802e 100755 (executable)
--- a/config.c
+++ b/config.c
@@ -150,12 +150,15 @@ char *ast_variable_retrieve(const struct ast_config *config, const char *categor
        struct ast_variable *v;
 
        if (category) {
-               for (v = ast_variable_browse(config, category); v; v = v->next)
+               char *val = NULL;
+               for (v = ast_variable_browse(config, category); v; v = v->next) {
                        if (variable == v->name)
                                return v->value;
-               for (v = ast_variable_browse(config, category); v; v = v->next)
                        if (!strcasecmp(variable, v->name))
-                               return v->value;
+                               val = v->value;
+               }
+               if (val)
+                       return val;
        } else {
                struct ast_category *cat;