[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fX-R=UGvb7a9hcFaRvWk-NiMvy9h2g+bKkTx5pQvjC9-A@mail.gmail.com>
Date: Wed, 20 Mar 2024 10:16:40 -0700
From: Ian Rogers <irogers@...gle.com>
To: Kuan-Wei Chiu <visitorckw@...il.com>
Cc: colyli@...e.de, kent.overstreet@...ux.dev, msakai@...hat.com,
peterz@...radead.org, mingo@...hat.com, acme@...nel.org, namhyung@...nel.org,
akpm@...ux-foundation.org, bfoster@...hat.com, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org, adrian.hunter@...el.com,
jserv@...s.ncku.edu.tw, dm-devel@...ts.linux.dev,
linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-bcachefs@...r.kernel.org, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v2 13/15] lib/test_min_heap: Use min_heap_init() for initializing
On Wed, Mar 20, 2024 at 7:55 AM Kuan-Wei Chiu <visitorckw@...il.com> wrote:
>
> Replace direct assignment of values to heap data members with
> min_heap_init() for better code readability and maintainability.
>
> Link: https://lkml.kernel.org/CAP-5=fW+FvUu8JL+KrtVv5uC++4AW=VhyEOgmdWzpH1mswQNzw@mail.gmail.com
> Signed-off-by: Kuan-Wei Chiu <visitorckw@...il.com>
Ah, got it :-)
Reviewed-by: Ian Rogers <irogers@...gle.com>
Thanks,
Ian
> ---
> lib/test_min_heap.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/lib/test_min_heap.c b/lib/test_min_heap.c
> index 062e908e9fa3..8d25fc8256db 100644
> --- a/lib/test_min_heap.c
> +++ b/lib/test_min_heap.c
> @@ -67,9 +67,8 @@ static __init int test_heapify_all(bool min_heap)
> -3, -1, -2, -4, 0x8000000, 0x7FFFFFF };
> struct min_heap_test heap;
>
> - heap.heap.data = values;
> + min_heap_init(&heap, values, ARRAY_SIZE(values));
> heap.heap.nr = ARRAY_SIZE(values);
> - heap.heap.size = ARRAY_SIZE(values);
> struct min_heap_callbacks funcs = {
> .less = min_heap ? less_than : greater_than,
> .swp = swap_ints,
> @@ -99,9 +98,7 @@ static __init int test_heap_push(bool min_heap)
> int values[ARRAY_SIZE(data)];
> struct min_heap_test heap;
>
> - heap.heap.data = values;
> - heap.heap.nr = 0;
> - heap.heap.size = ARRAY_SIZE(values);
> + min_heap_init(&heap, values, ARRAY_SIZE(values));
> struct min_heap_callbacks funcs = {
> .less = min_heap ? less_than : greater_than,
> .swp = swap_ints,
> @@ -131,9 +128,7 @@ static __init int test_heap_pop_push(bool min_heap)
> int values[ARRAY_SIZE(data)];
> struct min_heap_test heap;
>
> - heap.heap.data = values;
> - heap.heap.nr = 0;
> - heap.heap.size = ARRAY_SIZE(values);
> + min_heap_init(&heap, values, ARRAY_SIZE(values));
> struct min_heap_callbacks funcs = {
> .less = min_heap ? less_than : greater_than,
> .swp = swap_ints,
> --
> 2.34.1
>
Powered by blists - more mailing lists