t: Tweaked traversal to use more states, less indirect pointers
This splits LFSR_TSTATE_BTREE into separate LFSR_TSTATE_MTREE/BTREE/
OBTREE states that indicate what to do next after traversing the btree.
This removes the need to point indirectly to file's o.next pointer,
since we can just point to the file struct itself.
I've also simplified opened-file clobbering to just move to the next
opened mdir, instead of searching for another unsynced file. This
simplifies things but does mean we now need to clobber traversals when
closing non-file objects. Implicitly calling lfsr_opened_clobber in
lfsr_opened_remove solves this with very little extra code cost,
deduplicated, and gives us a stronger invariant for traversal references
to closed objects. So win win?
Oh, and all the explicit open-file clobber checks are now deduplicated
into lfsr_opened_clobber again.
These tweaks save quite a bit of code:
code stack
before: 34740 2624
after: 34570 (-0.5%) 2624 (+0.0%)
This commit is contained in:
@@ -613,7 +613,7 @@ typedef struct lfsr_mtraversal {
|
||||
|
||||
// opened file state, we use an indirect pointer here so we
|
||||
// always point to data associated with the current mid
|
||||
lfsr_omdir_t **ot;
|
||||
lfsr_omdir_t *ot;
|
||||
union {
|
||||
// cycle detection state, only valid when traversing the mroot chain
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user