From a96e2776cba6a57bf551665f0681a6aed6f2de74 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 30 Nov 2025 00:34:58 -0600 Subject: [PATCH] rattrs: Adopted LFS3_tag_RATTRS for LFS3_o_WRSET name creation Here's one interesting use-case for the single-recurse LFS3_tag_RATTRS: Avoiding a copy of the name creation rattrs in lfs3_file_sync_. There is a concern with nesting LFS3_tag_RATTRS in that it risks conflicts across layers, but currently this is ok as long as high-level LFS3_tag_RATTRS stick to non-negative mids (the mtree split commit in lfs3_mdir_commit_ only needs to recurse for mroot rattrs). Saves a bit of code: code stack ctx before: 35320 2176 660 after: 35316 (-0.0%) 2176 (+0.0%) 660 (+0.0%) code stack ctx gbmap before: 38172 2192 772 gbmap after: 38168 (-0.0%) 2192 (+0.0%) 772 (+0.0%) --- lfs3.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lfs3.c b/lfs3.c index b318c7b4..63111ee8 100644 --- a/lfs3.c +++ b/lfs3.c @@ -12413,7 +12413,8 @@ int lfs3_file_opencfg_(lfs3_t *lfs3, lfs3_file_t *file, LFS3_RATTR(4, LFS3_TAG_REG, +1, LFS3_FROM_NAME), LFS3_RATTR_ARG(did), LFS3_RATTR_ARG(path), - LFS3_RATTR_ARG(lfs3_path_namelen(path)))); + LFS3_RATTR_ARG(lfs3_path_namelen(path)), + LFS3_RATTR_NULL)); if (err) { goto failed; } @@ -14017,10 +14018,8 @@ static int lfs3_file_sync_(lfs3_t *lfs3, lfs3_file_t *file, if (lfs3_o_isunsync(file->b.h.flags)) { // explicit name? if (rname) { - LFS3_ASSERT(lfs3_rattr_len(rname) <= 4); - for (lfs3_size_t i = 0; i < lfs3_rattr_len(rname); i++) { - *r++ = rname[i]; - } + *r++ = LFS3_RATTR(2, LFS3_tag_RATTRS, +1); + *r++ = LFS3_RATTR_ARG(rname); // not created yet? need to convert to normal file } else if (lfs3_o_isuncreat(file->b.h.flags)) {