From 1b76bd04ce8c78988f617d7b57d73afde725f33c Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 22 Jun 2025 15:54:55 -0500 Subject: [PATCH] kv: Some minor file cache_buffer tweaks - Unconditionally pass buffer as cache_buffer in lfs3_set now that we rely on LFS3_o_WRSET - Swapped true -> 1 for non-null don't-care buffer pointer Saved one instruction as expected for the conditional assignment, but added a bit of stack. Weird, but probably just compiler noise: code stack ctx before: 37836 2408 636 after: 37832 (-0.0%) 2416 (+0.3%) 636 (+0.0%) --- lfs3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lfs3.c b/lfs3.c index b57433d1..a25c43f5 100644 --- a/lfs3.c +++ b/lfs3.c @@ -13939,7 +13939,7 @@ int lfs3_file_ckdata(lfs3_t *lfs3, lfs3_file_t *file) { // kv file config, we need to explicitly disable the file cache static const struct lfs3_file_config lfs3_file_kvconfig = { // TODO is this the best way to do this? - .cache_buffer = (uint8_t*)true, + .cache_buffer = (uint8_t*)1, .cache_size = 0, }; @@ -13998,7 +13998,7 @@ int lfs3_set(lfs3_t *lfs3, const char *path, // to try to commit small files atomically // struct lfs3_file_config cfg = { - .cache_buffer = (buffer) ? (uint8_t*)buffer : (uint8_t*)true, + .cache_buffer = (uint8_t*)buffer, .cache_size = size, }; lfs3_file_t file;