Skip to content

Commit 5cd103b

Browse files
spacewanderagentzh
authored andcommitted
optimize: avoided the string copy in ngx_http_lua_ffi_req_get_method_name().
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
1 parent 80fa32c commit 5cd103b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ngx_http_lua_req_method.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@ ngx_http_lua_ffi_req_get_method(ngx_http_request_t *r)
158158

159159

160160
int
161-
ngx_http_lua_ffi_req_get_method_name(ngx_http_request_t *r, char *buf,
161+
ngx_http_lua_ffi_req_get_method_name(ngx_http_request_t *r, u_char **name,
162162
size_t *len)
163163
{
164164
if (r->connection->fd == (ngx_socket_t) -1) {
165165
return NGX_HTTP_LUA_FFI_BAD_CONTEXT;
166166
}
167167

168-
*len = ngx_min(r->method_name.len, *len);
169-
ngx_memcpy(buf, r->method_name.data, *len);
168+
*name = r->method_name.data;
169+
*len = r->method_name.len;
170+
170171
return NGX_OK;
171172
}
172173

0 commit comments

Comments
 (0)