Skip to content

Commit d559bb2

Browse files
visitorckwakpm00
authored andcommitted
lib/test_min_heap: update min_heap_callbacks to use default builtin swap
Replace the swp function pointer in the min_heap_callbacks of test_min_heap with NULL, allowing direct usage of the default builtin swap implementation. This modification simplifies the code and improves performance by removing unnecessary function indirection. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kuan-Wei Chiu <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Ching-Chun (Jim) Huang <[email protected]> Cc: Coly Li <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: "Liang, Kan" <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Matthew Sakai <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 03ec56d commit d559bb2

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/test_min_heap.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ static __init bool greater_than(const void *lhs, const void *rhs, void __always_
2323
return *(int *)lhs > *(int *)rhs;
2424
}
2525

26-
static __init void swap_ints(void *lhs, void *rhs, void __always_unused *args)
27-
{
28-
int temp = *(int *)lhs;
29-
30-
*(int *)lhs = *(int *)rhs;
31-
*(int *)rhs = temp;
32-
}
33-
3426
static __init int pop_verify_heap(bool min_heap,
3527
struct min_heap_test *heap,
3628
const struct min_heap_callbacks *funcs)
@@ -72,7 +64,7 @@ static __init int test_heapify_all(bool min_heap)
7264
};
7365
struct min_heap_callbacks funcs = {
7466
.less = min_heap ? less_than : greater_than,
75-
.swp = swap_ints,
67+
.swp = NULL,
7668
};
7769
int i, err;
7870

@@ -104,7 +96,7 @@ static __init int test_heap_push(bool min_heap)
10496
};
10597
struct min_heap_callbacks funcs = {
10698
.less = min_heap ? less_than : greater_than,
107-
.swp = swap_ints,
99+
.swp = NULL,
108100
};
109101
int i, temp, err;
110102

@@ -136,7 +128,7 @@ static __init int test_heap_pop_push(bool min_heap)
136128
};
137129
struct min_heap_callbacks funcs = {
138130
.less = min_heap ? less_than : greater_than,
139-
.swp = swap_ints,
131+
.swp = NULL,
140132
};
141133
int i, temp, err;
142134

@@ -175,7 +167,7 @@ static __init int test_heap_del(bool min_heap)
175167
heap.nr = ARRAY_SIZE(values);
176168
struct min_heap_callbacks funcs = {
177169
.less = min_heap ? less_than : greater_than,
178-
.swp = swap_ints,
170+
.swp = NULL,
179171
};
180172
int i, err;
181173

0 commit comments

Comments
 (0)