mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
reftable/block: simplify how we track restart points
Restart points record the location of reftable records that do not use
prefix compression and are used to perform a binary search inside of a
block. These restart points are encoded at the end of a block, between
the record data and the footer of a table.
The block structure contains three different variables related to these
restart points:
- The block length contains the length of the reftable block up to the
restart points.
- The restart count contains the number of restart points contained in
the block.
- The restart bytes variable tracks where the restart point data
begins.
Tracking all three of these variables is unnecessary though as the data
can be derived from one another: the block length without restart points
is the exact same as the offset of the restart count data, which we
already track via the `restart_bytes` data.
Refactor the code so that we track the location of restart bytes not as
a pointer, but instead as an offset. This allows us to trivially get rid
of the `block_len` variable as described above. This avoids having the
confusing `block_len` variable and allows us to do less bookkeeping
overall.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1ac4e5e83d
commit
ba620d296a
@@ -79,10 +79,12 @@ struct block_reader {
|
||||
unsigned char *uncompressed_data;
|
||||
size_t uncompressed_cap;
|
||||
|
||||
/* size of the data, excluding restart data. */
|
||||
uint32_t block_len;
|
||||
uint8_t *restart_bytes;
|
||||
/*
|
||||
* Restart point data. Restart points are located after the block's
|
||||
* record data.
|
||||
*/
|
||||
uint16_t restart_count;
|
||||
uint32_t restart_off;
|
||||
|
||||
/* size of the data in the file. For log blocks, this is the compressed
|
||||
* size. */
|
||||
|
||||
Reference in New Issue
Block a user