diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-15 23:45:31 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-01-13 10:32:56 +0000 |
commit | 31f03d9433ed4a2aa3e13056f93909632b78fbf0 (patch) | |
tree | 0f1a546589cc230f19815024c767e69036c43996 | |
parent | 1e9ad3ca0d9bf3e917eb2beb460421155144760a (diff) | |
download | rockbox-31f03d9433.tar.gz rockbox-31f03d9433.zip |
buflib: Optimize away the BSIZE metadata field
Now that allocations are unnamed, BSIZE is a constant.
Change-Id: Iab52cbebe426ea0d12f428582347e20ed243367f
-rw-r--r-- | firmware/buflib.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c index 8fc32f7406..457a47b109 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c @@ -127,15 +127,14 @@ enum { #ifdef BUFLIB_HAS_CRC bidx_CRC, /* CRC, protects all metadata behind it */ #endif - bidx_BSIZE, /* total size of the block header */ }; /* Number of fields in the block header. Note that bidx_USER is not an * actual field so it is not included in the count. */ #ifdef BUFLIB_HAS_CRC -# define BUFLIB_NUM_FIELDS 6 -#else # define BUFLIB_NUM_FIELDS 5 +#else +# define BUFLIB_NUM_FIELDS 4 #endif struct buflib_callbacks buflib_ops_locked = { @@ -339,7 +338,7 @@ union buflib_data* handle_to_block(struct buflib_context* ctx, int handle) return NULL; union buflib_data *data = ALIGN_DOWN(ptr, sizeof(*data)); - return data - data[-bidx_BSIZE].val; + return data - BUFLIB_NUM_FIELDS; } /* Get the block end pointer from a handle table entry */ @@ -740,10 +739,8 @@ buffer_alloc: block[fidx_HANDLE].handle = handle; block[fidx_OPS].ops = ops; - size_t bsize = BUFLIB_NUM_FIELDS; - union buflib_data *block_end = block + bsize; + union buflib_data *block_end = block + BUFLIB_NUM_FIELDS; block_end[-bidx_PIN].pincount = 0; - block_end[-bidx_BSIZE].val = bsize; update_block_crc(ctx, block, block_end); handle->alloc = (char*)&block_end[-bidx_USER]; |