mirror of
https://github.com/git/git.git
synced 2024-11-27 12:03:55 +08:00
reftable/block: merge block_iter_seek()
and block_reader_seek()
The function `block_iter_seek()` is merely a simple wrapper around `block_reader_seek()`. Merge those two functions into a new function `block_iter_seek_key()` that more clearly says what it is actually doing. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3122d44025
commit
42c7bdc36d
@ -373,19 +373,14 @@ int block_reader_first_key(struct block_reader *br, struct strbuf *key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int block_iter_seek(struct block_iter *it, struct strbuf *want)
|
||||
{
|
||||
return block_reader_seek(it->br, it, want);
|
||||
}
|
||||
|
||||
void block_iter_close(struct block_iter *it)
|
||||
{
|
||||
strbuf_release(&it->last_key);
|
||||
strbuf_release(&it->scratch);
|
||||
}
|
||||
|
||||
int block_reader_seek(struct block_reader *br, struct block_iter *it,
|
||||
struct strbuf *want)
|
||||
int block_iter_seek_key(struct block_iter *it, struct block_reader *br,
|
||||
struct strbuf *want)
|
||||
{
|
||||
struct restart_needle_less_args args = {
|
||||
.needle = *want,
|
||||
|
@ -101,8 +101,8 @@ int block_reader_init(struct block_reader *br, struct reftable_block *bl,
|
||||
void block_iter_seek_start(struct block_iter *it, struct block_reader *br);
|
||||
|
||||
/* Position `it` to the `want` key in the block */
|
||||
int block_reader_seek(struct block_reader *br, struct block_iter *it,
|
||||
struct strbuf *want);
|
||||
int block_iter_seek_key(struct block_iter *it, struct block_reader *br,
|
||||
struct strbuf *want);
|
||||
|
||||
/* Returns the block type (eg. 'r' for refs) */
|
||||
uint8_t block_reader_type(struct block_reader *r);
|
||||
@ -115,9 +115,6 @@ void block_iter_copy_from(struct block_iter *dest, struct block_iter *src);
|
||||
/* return < 0 for error, 0 for OK, > 0 for EOF. */
|
||||
int block_iter_next(struct block_iter *it, struct reftable_record *rec);
|
||||
|
||||
/* Seek to `want` with in the block pointed to by `it` */
|
||||
int block_iter_seek(struct block_iter *it, struct strbuf *want);
|
||||
|
||||
/* deallocate memory for `it`. The block reader and its block is left intact. */
|
||||
void block_iter_close(struct block_iter *it);
|
||||
|
||||
|
@ -89,7 +89,7 @@ static void test_block_read_write(void)
|
||||
strbuf_reset(&want);
|
||||
strbuf_addstr(&want, names[i]);
|
||||
|
||||
n = block_reader_seek(&br, &it, &want);
|
||||
n = block_iter_seek_key(&it, &br, &want);
|
||||
EXPECT(n == 0);
|
||||
|
||||
n = block_iter_next(&it, &rec);
|
||||
@ -98,7 +98,7 @@ static void test_block_read_write(void)
|
||||
EXPECT_STREQ(names[i], rec.u.ref.refname);
|
||||
|
||||
want.len--;
|
||||
n = block_reader_seek(&br, &it, &want);
|
||||
n = block_iter_seek_key(&it, &br, &want);
|
||||
EXPECT(n == 0);
|
||||
|
||||
n = block_iter_next(&it, &rec);
|
||||
|
@ -483,7 +483,7 @@ static int reader_seek_linear(struct table_iter *ti,
|
||||
table_iter_copy_from(ti, &next);
|
||||
}
|
||||
|
||||
err = block_iter_seek(&ti->bi, &want_key);
|
||||
err = block_iter_seek_key(&ti->bi, ti->bi.br, &want_key);
|
||||
if (err < 0)
|
||||
goto done;
|
||||
err = 0;
|
||||
@ -558,7 +558,7 @@ static int reader_seek_indexed(struct reftable_reader *r,
|
||||
if (err != 0)
|
||||
goto done;
|
||||
|
||||
err = block_iter_seek(&next.bi, &want_index.u.idx.last_key);
|
||||
err = block_iter_seek_key(&next.bi, next.bi.br, &want_index.u.idx.last_key);
|
||||
if (err < 0)
|
||||
goto done;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user