Message ID | 20240830075403.3540985-1-lihongbo22@huawei.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [-next] ACPICA: Use swap() to improve code | expand |
On Fri, Aug 30, 2024 at 9:46 AM Hongbo Li <lihongbo22@huawei.com> wrote: > > Use the swap() macro to simplify the code and improve its > readability. > > The target code segment uses the bubble sort, we can use > this macro to simplify the code. > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com> To make changes in ACPICA, please submit a pull request to the upstream ACPICA project on GitHub. Once your upstream ACPICA pull request has been merged, please submit a corresponding Linux patch pointing to the original upstream ACPICA commit. Thanks! > --- > drivers/acpi/acpica/nsrepair2.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c > index 1bb7b71f07f1..5d56b2fd9151 100644 > --- a/drivers/acpi/acpica/nsrepair2.c > +++ b/drivers/acpi/acpica/nsrepair2.c > @@ -875,7 +875,6 @@ acpi_ns_sort_list(union acpi_operand_object **elements, > { > union acpi_operand_object *obj_desc1; > union acpi_operand_object *obj_desc2; > - union acpi_operand_object *temp_obj; > u32 i; > u32 j; > > @@ -891,11 +890,8 @@ acpi_ns_sort_list(union acpi_operand_object **elements, > obj_desc2->integer.value)) > || ((sort_direction == ACPI_SORT_DESCENDING) > && (obj_desc1->integer.value < > - obj_desc2->integer.value))) { > - temp_obj = elements[j - 1]; > - elements[j - 1] = elements[j]; > - elements[j] = temp_obj; > - } > + obj_desc2->integer.value))) > + swap(elements[j - 1], elements[j]); > } > } > } > -- > 2.34.1 > >
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c index 1bb7b71f07f1..5d56b2fd9151 100644 --- a/drivers/acpi/acpica/nsrepair2.c +++ b/drivers/acpi/acpica/nsrepair2.c @@ -875,7 +875,6 @@ acpi_ns_sort_list(union acpi_operand_object **elements, { union acpi_operand_object *obj_desc1; union acpi_operand_object *obj_desc2; - union acpi_operand_object *temp_obj; u32 i; u32 j; @@ -891,11 +890,8 @@ acpi_ns_sort_list(union acpi_operand_object **elements, obj_desc2->integer.value)) || ((sort_direction == ACPI_SORT_DESCENDING) && (obj_desc1->integer.value < - obj_desc2->integer.value))) { - temp_obj = elements[j - 1]; - elements[j - 1] = elements[j]; - elements[j] = temp_obj; - } + obj_desc2->integer.value))) + swap(elements[j - 1], elements[j]); } } }
Use the swap() macro to simplify the code and improve its readability. The target code segment uses the bubble sort, we can use this macro to simplify the code. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/acpi/acpica/nsrepair2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)