Skip to content

Commit 3f33dd8

Browse files
Miniwofferdoujiang24
authored andcommitted
optimization: removed superfluous code from shdict_store. (#1956)
avoid setting the key_len, key_data and value_len fields since they already have the same values when replacing the value data.
1 parent 560461e commit 3f33dd8

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/ngx_http_lua_shdict.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,6 @@ ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
14261426
ngx_queue_remove(&sd->queue);
14271427
ngx_queue_insert_head(&ctx->sh->lru_queue, &sd->queue);
14281428

1429-
sd->key_len = (u_short) key_len;
1430-
14311429
if (exptime > 0) {
14321430
tp = ngx_timeofday();
14331431
sd->expires = (uint64_t) tp->sec * 1000 + tp->msec
@@ -1439,14 +1437,11 @@ ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
14391437

14401438
sd->user_flags = user_flags;
14411439

1442-
sd->value_len = (uint32_t) str_value_len;
1443-
14441440
dd("setting value type to %d", value_type);
14451441

14461442
sd->value_type = (uint8_t) value_type;
14471443

1448-
p = ngx_copy(sd->data, key, key_len);
1449-
ngx_memcpy(p, str_value_buf, str_value_len);
1444+
ngx_memcpy(sd->data + key_len, str_value_buf, str_value_len);
14501445

14511446
ngx_shmtx_unlock(&ctx->shpool->mutex);
14521447

0 commit comments

Comments
 (0)