summaryrefslogtreecommitdiff
path: root/items.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-07-03 18:41:05 -0700
committerdormando <dormando@rydia.net>2017-07-03 18:41:05 -0700
commit830b20f7b9f34d4d650d2e9b7340957f2e00fa11 (patch)
treedebb0db9a154e467e877e57f64c9016926b05d08 /items.c
parentad909901c1aa1c38ad0409ca0b700c03a7c17932 (diff)
downloadmemcached-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.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/items.c b/items.c
index fdfa38d..637e5e7 100644
--- a/items.c
+++ b/items.c
@@ -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;