Hi, this is the second version of my patch series that refactors the `binsearch()` mechanism in the reftable library. There's only a single change compared to v1, namely a renamed struct. Thanks! Patrick Patrick Steinhardt (7): reftable/basics: fix return type of `binsearch()` to be `size_t` reftable/basics: improve `binsearch()` test reftable/refname: refactor binary search over refnames reftable/block: refactor binary search over restart points reftable/block: fix error handling when searching restart points reftable/record: extract function to decode key lengths reftable/block: avoid decoding keys when searching restart points reftable/basics.c | 7 ++- reftable/basics.h | 7 +-- reftable/basics_test.c | 55 +++++++++++--------- reftable/block.c | 114 ++++++++++++++++++++++++++++++----------- reftable/record.c | 34 ++++++++---- reftable/record.h | 6 +++ reftable/refname.c | 53 +++++++++---------- 7 files changed, 179 insertions(+), 97 deletions(-) Range-diff against v1: 1: cd82ac6531 = 1: cd82ac6531 reftable/basics: fix return type of `binsearch()` to be `size_t` 2: 7955f7983a ! 2: a277d4fa6f reftable/basics: improve `binsearch()` test @@ reftable/basics_test.c: license that can be found in the LICENSE file or at -struct binsearch_args { - int key; - int *arr; -+struct integer_needle_lesseq { ++struct integer_needle_lesseq_args { + int needle; + int *haystack; }; @@ reftable/basics_test.c: license that can be found in the LICENSE file or at - struct binsearch_args *args = void_args; - - return args->key < args->arr[i]; -+ struct integer_needle_lesseq *args = _args; ++ struct integer_needle_lesseq_args *args = _args; + return args->needle <= args->haystack[i]; } @@ reftable/basics_test.c: license that can be found in the LICENSE file or at - args.key = i; - res = binsearch(sz, &binsearch_func, &args); + for (i = 0; i < ARRAY_SIZE(testcases); i++) { -+ struct integer_needle_lesseq args = { ++ struct integer_needle_lesseq_args args = { + .haystack = haystack, + .needle = testcases[i].needle, + }; 3: 44386818ce = 3: 9ffcf45c32 reftable/refname: refactor binary search over refnames 4: f56275f288 = 4: 5e20d93ae0 reftable/block: refactor binary search over restart points 5: 36b1ef8e5c = 5: 5bbeab114f reftable/block: fix error handling when searching restart points 6: 38666de451 = 6: 271bacb210 reftable/record: extract function to decode key lengths 7: f716400686 = 7: e751b3c536 reftable/block: avoid decoding keys when searching restart points -- 2.44.GIT
Attachment:
signature.asc
Description: PGP signature