diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-11-13 20:41:41 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-11-13 20:41:41 +0000 |
commit | 950fb268a2b89f782d8f74278a3878651aa3df6f (patch) | |
tree | 7a6d9124c0982f09223fd773aef6db5a6cb0dff6 /src | |
parent | 30870b4ab31b4582af200b0abbaae47a6366a7d0 (diff) | |
download | nginx-950fb268a2b89f782d8f74278a3878651aa3df6f.tar.gz nginx-950fb268a2b89f782d8f74278a3878651aa3df6f.zip |
ngx_regex_exec() calling optimiztion:
*) change NGX_REGEX_NO_MATCHED to PCRE_ERROR_NOMATCH
*) declare ngx_regex_exec() as #define
*) optimize SSI regex a little
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ngx_regex.c | 16 | ||||
-rw-r--r-- | src/core/ngx_regex.h | 9 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssi_filter_module.c | 2 |
3 files changed, 7 insertions, 20 deletions
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c index be2dae79b..c5a495209 100644 --- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -99,22 +99,6 @@ ngx_regex_capture_count(ngx_regex_t *re) ngx_int_t -ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures, ngx_int_t size) -{ - int rc; - - rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0, - captures, size); - - if (rc == -1) { - return NGX_REGEX_NO_MATCHED; - } - - return rc; -} - - -ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log) { ngx_int_t n; diff --git a/src/core/ngx_regex.h b/src/core/ngx_regex.h index e31470f9f..4a4857222 100644 --- a/src/core/ngx_regex.h +++ b/src/core/ngx_regex.h @@ -14,7 +14,7 @@ #include <pcre.h> -#define NGX_REGEX_NO_MATCHED -1000 +#define NGX_REGEX_NO_MATCHED PCRE_ERROR_NOMATCH /* -1 */ #define NGX_REGEX_CASELESS PCRE_CASELESS @@ -30,8 +30,11 @@ void ngx_regex_init(void); ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, ngx_pool_t *pool, ngx_str_t *err); ngx_int_t ngx_regex_capture_count(ngx_regex_t *re); -ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures, - ngx_int_t size); + +#define ngx_regex_exec(re, s, captures, size) \ + pcre_exec(re, NULL, (const char *) (s)->data, (s)->len, 0, 0, \ + captures, size) + ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log); diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index d03e58407..f06994db3 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -2468,7 +2468,7 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, rc = ngx_regex_exec(regex, &left, NULL, 0); - if (rc != NGX_REGEX_NO_MATCHED && rc < 0) { + if (rc < NGX_REGEX_NO_MATCHED) { ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", rc, &left, &right); |