Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[.joined/src/trunk]: .joined/src/usr.bin/make make: convert do-while into whi...



details:   https://anonhg.NetBSD.org/.joined/src/rev/6b5284efb36b
branches:  trunk
changeset: 359386:6b5284efb36b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 01 21:04:15 2022 +0000

description:
make: convert do-while into while in FindKeyword

GCC generates more efficient code; previously it wasn't aware that (end
- start) was always positive, thus allowing to omit the code for
dividing a negative number by 2.

No functional change.

diffstat:

 usr.bin/make/parse.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r b84f84ef31e7 -r 6b5284efb36b usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Jan 01 21:01:21 2022 +0000
+++ b/usr.bin/make/parse.c      Sat Jan 01 21:04:15 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.610 2022/01/01 19:44:05 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.611 2022/01/01 21:04:15 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.610 2022/01/01 19:44:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.611 2022/01/01 21:04:15 rillig Exp $");
 
 /* types and constants */
 
@@ -539,7 +539,7 @@
        int start = 0;
        int end = sizeof parseKeywords / sizeof parseKeywords[0] - 1;
 
-       do {
+       while (start <= end) {
                int curr = start + (end - start) / 2;
                int diff = strcmp(str, parseKeywords[curr].name);
 
@@ -549,7 +549,7 @@
                        end = curr - 1;
                else
                        start = curr + 1;
-       } while (start <= end);
+       }
 
        return -1;
 }



Home | Main Index | Thread Index | Old Index