diff options
author | dormando <dormando@rydia.net> | 2017-07-03 18:41:05 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-07-03 18:41:05 -0700 |
commit | 830b20f7b9f34d4d650d2e9b7340957f2e00fa11 (patch) | |
tree | debb0db9a154e467e877e57f64c9016926b05d08 /items.c | |
parent | ad909901c1aa1c38ad0409ca0b700c03a7c17932 (diff) | |
download | memcached-830b20f7b9f34d4d650d2e9b7340957f2e00fa11.tar.gz |
save four bytes per item if client flags are 0
If the size of the flags are 0, it can easily mean to not store anything at
all.
Diffstat (limited to 'items.c')
-rw-r--r-- | items.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -169,7 +169,11 @@ static size_t item_make_header(const uint8_t nkey, const unsigned int flags, con /* suffix is defined at 40 chars elsewhere.. */ *nsuffix = (uint8_t) snprintf(suffix, 40, " %u %d\r\n", flags, nbytes - 2); } else { - *nsuffix = sizeof(flags); + if (flags == 0) { + *nsuffix = 0; + } else { + *nsuffix = sizeof(flags); + } } return sizeof(item) + nkey + *nsuffix + nbytes; } @@ -322,7 +326,7 @@ item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, it->exptime = exptime; if (settings.inline_ascii_response) { memcpy(ITEM_suffix(it), suffix, (size_t)nsuffix); - } else { + } else if (nsuffix > 0) { memcpy(ITEM_suffix(it), &flags, sizeof(flags)); } it->nsuffix = nsuffix; |