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
This commit is contained in:
parent
72edbfbb36
commit
f50c6bd9fc
3 changed files with 7 additions and 20 deletions
|
@ -98,22 +98,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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue