diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-09 13:05:02 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-12 13:40:57 +0400 |
commit | 86c02614608eb7e9e78c09cdec69aeba689edae8 (patch) | |
tree | 2df0cad2d55cb8bbd6a5b87b231ebef0cf9631f7 /src/config.c | |
parent | d8289b9fb416cfe4f83eeb38fe324c077bada3e4 (diff) |
config: deduplicate iterator creation
When the glob iterator is passed NULL regexp, call the non-globbing
iterator so we don't have to special-case which functions to call.
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/config.c b/src/config.c index 061765ac0..ae4e4816a 100644 --- a/src/config.c +++ b/src/config.c @@ -449,23 +449,20 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf all_iter *iter; int result; + if (regexp == NULL) + return git_config_iterator_new(out, cfg); + iter = git__calloc(1, sizeof(all_iter)); GITERR_CHECK_ALLOC(iter); - if (regexp != NULL) { - if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) { - giterr_set_regex(&iter->regex, result); - regfree(&iter->regex); - return -1; - } - - iter->parent.next = all_iter_glob_next; - iter->parent.free = all_iter_glob_free; - } else { - iter->parent.next = all_iter_next; - iter->parent.free = all_iter_free; + if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) { + giterr_set_regex(&iter->regex, result); + regfree(&iter->regex); + return -1; } + iter->parent.next = all_iter_glob_next; + iter->parent.free = all_iter_glob_free; iter->i = cfg->files.length; iter->cfg = cfg; |