Switched to writing compat flags as le32s
Most of littlefs's metadata is encoded in leb128s now, with the
exception of tags (be16, sort of), revision counts (le32), cksums
(le32), and flags.
It makes sense for tags to be a special case, these are written and
rewritten _everywhere_, but less so for flags, which are only written to
the mroot and updated infrequently.
We might as well save a bit of code by reusing our le32 machinery.
---
This changes lfsr_format to just write out compat flags as le32s, saving
a tiny bit of code at the cost of a tiny bit of disk usage (the real
benefit being a tiny bit of code simplification):
code stack ctx
before: 37792 2608 620
after: 37772 (-0.1%) 2608 (+0.0%) 620 (+0.0%)
Compat already need to handle trailing zeros gracefully, so this doesn't
change anything at mount time.
Also had to switch from enums to #defines thanks to C's broken enums.
Wooh. We already use #defines for the other flags for this reason.
This commit is contained in:
+3
-3
@@ -1169,13 +1169,13 @@ class Config:
|
||||
return 'version v%d.%d' % self.version
|
||||
elif tag == TAG_RCOMPAT:
|
||||
return 'rcompat 0x%s' % ''.join(
|
||||
'%x' % f for f in reversed(self.rcompat))
|
||||
'%02x' % f for f in reversed(self.rcompat))
|
||||
elif tag == TAG_WCOMPAT:
|
||||
return 'wcompat 0x%s' % ''.join(
|
||||
'%x' % f for f in reversed(self.wcompat))
|
||||
'%02x' % f for f in reversed(self.wcompat))
|
||||
elif tag == TAG_OCOMPAT:
|
||||
return 'ocompat 0x%s' % ''.join(
|
||||
'%x' % f for f in reversed(self.ocompat))
|
||||
'%02x' % f for f in reversed(self.ocompat))
|
||||
elif tag == TAG_GEOMETRY:
|
||||
return 'geometry %dx%d' % self.geometry
|
||||
elif tag == TAG_NAMELIMIT:
|
||||
|
||||
Reference in New Issue
Block a user