From 830b20f7b9f34d4d650d2e9b7340957f2e00fa11 Mon Sep 17 00:00:00 2001 From: dormando Date: Mon, 3 Jul 2017 18:41:05 -0700 Subject: 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. --- items.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'items.c') 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; -- cgit v1.2.1