optimize: fixed the initial table sizes for "ngx", "ngx.config", and "ngx.re".

This commit is contained in:
Yichun Zhang (agentzh) 2013-08-31 17:34:36 -07:00
Родитель 9577e5fc58
Коммит c752049275
4 изменённых файлов: 47 добавлений и 7 удалений

Просмотреть файл

@ -18,7 +18,7 @@ ngx_http_lua_inject_config_api(lua_State *L)
{
/* ngx.config */
lua_newtable(L); /* .config */
lua_createtable(L, 0, 1 /* nrec */); /* .config */
#if (NGX_DEBUG)
lua_pushboolean(L, 1);

Просмотреть файл

@ -1807,7 +1807,7 @@ ngx_http_lua_inject_regex_api(lua_State *L)
{
/* ngx.re */
lua_newtable(L); /* .re */
lua_createtable(L, 0, 4 /* nrec */); /* .re */
lua_pushcfunction(L, ngx_http_lua_ngx_re_match);
lua_setfield(L, -2, "match");

Просмотреть файл

@ -743,7 +743,7 @@ ngx_http_lua_inject_ngx_api(ngx_conf_t *cf, lua_State *L)
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_lua_module);
lua_createtable(L, 0 /* narr */, 95 /* nrec */); /* ngx.* */
lua_createtable(L, 0 /* narr */, 96 /* nrec */); /* ngx.* */
ngx_http_lua_inject_arg_api(L);

Просмотреть файл

@ -35,7 +35,7 @@ __DATA__
--- request
GET /test
--- response_body
ngx: 95
ngx: 96
--- no_error_log
[error]
@ -56,7 +56,7 @@ ngx: 95
--- request
GET /test
--- response_body
95
96
--- no_error_log
[error]
@ -84,7 +84,7 @@ GET /test
--- request
GET /test
--- response_body
n = 95
n = 96
--- no_error_log
[error]
@ -301,7 +301,7 @@ GET /t
--- response_body_like: 404 Not Found
--- error_code: 404
--- error_log
ngx. entry count: 95
ngx. entry count: 96
@ -323,3 +323,43 @@ n = 1
--- no_error_log
[error]
=== TEST 15: entries under ngx.config
--- config
location = /test {
content_by_lua '
local n = 0
for k, v in pairs(ngx.config) do
n = n + 1
end
ngx.say("n = ", n)
';
}
--- request
GET /test
--- response_body
n = 1
--- no_error_log
[error]
=== TEST 16: entries under ngx.re
--- config
location = /test {
content_by_lua '
local n = 0
for k, v in pairs(ngx.re) do
n = n + 1
end
ngx.say("n = ", n)
';
}
--- request
GET /test
--- response_body
n = 4
--- no_error_log
[error]