Files
littlefs/tests
Christopher Haster e15412d1d6 Adopted lazy encoding for le32 and leb128 attrs
- LFSR_TAG_RCOMPAT     -+-> lfsr_data_fromle32
- LFSR_TAG_WCOMPAT     -+
- LFSR_TAG_OCOMPAT     -+
- LFSR_TAG_GCKSUMDELTA -'
- LFSR_TAG_NAMELIMIT   -+-> lfsr_data_fromleb128
- LFSR_TAG_FILELIMIT   -+
- LFSR_TAG_BOOKMARK    -+
- LFSR_TAG_DID         -'

This is nice mainly from an internal API standpoint. Single le32/leb128
attrs should be pretty lightweight, and it's nice for the API to reflect
that.

With a bit of tinkering with the internal lfsr_rattr_t type, we can even
pass these directly in the lfsr_rattr_t struct itself, so no need to
keep single le32/leb128 attrs on the stack:

  buffer rattr:        cat attr:            le32/leb128 attr:
  .---+---+---+---. .. .---+---+---+---. .. .---+---+---+---.
  |  tag  |0|size |    |  tag  |1|count|    |  tag  |0|dsize|
  +---+---+---+---+    +---+---+---+---+    +---+---+---+---+
  |     weight    |    |     weight    |    |     weight    |
  +---+---+---+---+ .. +---+---+---+---+ .. +---+---+---+---+
  |      ptr -------.  |      ptr -------.  |  le32/leb128  |
  '---+---+---+---' |  '---+---+---+---' |  '---+---+---+---'
  .---+---+---+---. |  .---+---+---+---. |
  |      data     |<'  |mm|   size     |<'
  :       :       :    +---+---+---+---+
                       |      data     |
                       +               +
                       |               |
                       +---+---+---+---+
                       |mm|   size     |
                       :       :       :

While tinkering I also ended up renaming a couple things:

- rattr.cat -> rattr.u.datas, rattr.u.buffer, rattr.u.etc
- rattr.count -> rattr.data_count
- added lfsr_rattr_dtag for ignoring on-disk/explicit-data tags
- lfsr_rattr_size -> lfsr_rattr_dsize

Surprisingly very little code savings though. I guess we don't use
single le32/leb128 attrs enough to overcome the added complexity to
lfsr_rbyd_appendrattr_'s switch-case-table?

           code          stack          ctx
  before: 35636           2440          636
  after:  35632 (-0.0%)   2440 (+0.0%)  636 (+0.0%)

That or there's something else weird going on with this union and
compiler assumptions. Attempting to adopt .u.etc in LFSR_RATTR__ alone
adds ~100 bytes of code, even though both .u.etc and .u.cat are the same
type (const void *)...

Not entirely sure what's going on...
2025-02-11 02:51:42 -06:00
..
2024-08-20 19:59:08 -05:00