Took advantage of file buffer layout to pass as lfsr_data_t directly
This would have been more valuable if the extra lfsr_data_t stack
allocation (12 bytes) wasn't already unioned with the btree's encoding
buffer allocation (18 bytes):
code stack
before: 33714 2640
after: 33702 (-0.0%) 2640 (+0.0%)
Oh well, this still might save some stack in the future if things shift
around.
This commit is contained in:
@@ -11452,10 +11452,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
|
|||||||
lfsr_attr_t attrs[2];
|
lfsr_attr_t attrs[2];
|
||||||
lfs_size_t attr_count = 0;
|
lfs_size_t attr_count = 0;
|
||||||
lfsr_data_t name_data;
|
lfsr_data_t name_data;
|
||||||
union {
|
uint8_t buf[LFSR_BTREE_DSIZE];
|
||||||
lfsr_data_t data;
|
|
||||||
uint8_t buf[LFSR_BTREE_DSIZE];
|
|
||||||
} data;
|
|
||||||
|
|
||||||
// not created yet? need to convert orphan to normal file
|
// not created yet? need to convert orphan to normal file
|
||||||
if (lfsr_f_isorphan(file->m.flags)) {
|
if (lfsr_f_isorphan(file->m.flags)) {
|
||||||
@@ -11481,10 +11478,9 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
|
|||||||
LFSR_DATA_NULL());
|
LFSR_DATA_NULL());
|
||||||
// small file inlined in mdir?
|
// small file inlined in mdir?
|
||||||
} else if (lfsr_f_isunflush(file->m.flags)) {
|
} else if (lfsr_f_isunflush(file->m.flags)) {
|
||||||
data.data = LFSR_DATA_BUF(file->buffer.buffer, file->buffer.size);
|
|
||||||
attrs[attr_count++] = LFSR_ATTR_CAT_(
|
attrs[attr_count++] = LFSR_ATTR_CAT_(
|
||||||
LFSR_TAG_SUB | LFSR_TAG_DATA, 0,
|
LFSR_TAG_SUB | LFSR_TAG_DATA, 0,
|
||||||
&data.data, 1);
|
(const lfsr_data_t*)&file->buffer, 1);
|
||||||
// bshrub?
|
// bshrub?
|
||||||
} else if (lfsr_bshrub_isbshrub(&file->m.mdir, &file->bshrub)) {
|
} else if (lfsr_bshrub_isbshrub(&file->m.mdir, &file->bshrub)) {
|
||||||
attrs[attr_count++] = LFSR_ATTR_SHRUBTRUNK(
|
attrs[attr_count++] = LFSR_ATTR_SHRUBTRUNK(
|
||||||
@@ -11494,7 +11490,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
|
|||||||
} else if (lfsr_bshrub_isbtree(&file->m.mdir, &file->bshrub)) {
|
} else if (lfsr_bshrub_isbtree(&file->m.mdir, &file->bshrub)) {
|
||||||
attrs[attr_count++] = LFSR_ATTR(
|
attrs[attr_count++] = LFSR_ATTR(
|
||||||
LFSR_TAG_SUB | LFSR_TAG_BTREE, 0,
|
LFSR_TAG_SUB | LFSR_TAG_BTREE, 0,
|
||||||
LFSR_DATA_BTREE_(&file->bshrub.u.btree, data.buf));
|
LFSR_DATA_BTREE_(&file->bshrub.u.btree, buf));
|
||||||
} else {
|
} else {
|
||||||
LFS_UNREACHABLE();
|
LFS_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,10 +519,11 @@ typedef struct lfsr_file {
|
|||||||
lfsr_bshrub_t bshrub_;
|
lfsr_bshrub_t bshrub_;
|
||||||
lfs_off_t pos;
|
lfs_off_t pos;
|
||||||
|
|
||||||
|
// note this lines up with lfsr_data_t's buffer representation
|
||||||
struct {
|
struct {
|
||||||
lfs_off_t pos;
|
|
||||||
lfs_off_t size;
|
lfs_off_t size;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
|
lfs_off_t pos;
|
||||||
} buffer;
|
} buffer;
|
||||||
|
|
||||||
lfs_block_t eblock;
|
lfs_block_t eblock;
|
||||||
|
|||||||
Reference in New Issue
Block a user