git: f076dd3ef02d - main - imgact_elf: Optimize pagesizes[] loop
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 02 Aug 2024 23:35:27 UTC
The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=f076dd3ef02ddf7799eeaab8d405ee9d845e8dc6 commit f076dd3ef02ddf7799eeaab8d405ee9d845e8dc6 Author: Alan Cox <alc@FreeBSD.org> AuthorDate: 2024-07-15 06:02:33 +0000 Commit: Alan Cox <alc@FreeBSD.org> CommitDate: 2024-08-02 23:26:11 +0000 imgact_elf: Optimize pagesizes[] loop Except for elements whose value is zero, the elements of pagesizes[] are always sorted in increasing order, so once a loop starting from the end of the array has found a non-zero element, it has found the largest valued element and can stop iterating. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46215 --- sys/kern/imgact_elf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index a623a63e9c2e..28ffdd03dd6d 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1158,8 +1158,10 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) maxalign = PAGE_SIZE; maxsalign = PAGE_SIZE * 1024; for (i = MAXPAGESIZES - 1; i > 0; i--) { - if (pagesizes[i] > maxsalign) + if (pagesizes[i] > maxsalign) { maxsalign = pagesizes[i]; + break; + } } mapsz = 0;