Module Name:    src
Committed By:   rillig
Date:           Tue Dec  7 23:20:09 UTC 2021

Modified Files:
        src/usr.bin/make: parse.c

Log Message:
make: inline common subexpression in ParseRawLine

There is no need to load the buf_end from memory each time a character
from a makefile is processed.  The end of the buffer only changes when
the file changes, not while reading a single line.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.569 -r1.570 src/usr.bin/make/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.569 src/usr.bin/make/parse.c:1.570
--- src/usr.bin/make/parse.c:1.569	Sat Dec  4 23:47:09 2021
+++ src/usr.bin/make/parse.c	Tue Dec  7 23:20:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.569 2021/12/04 23:47:09 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.570 2021/12/07 23:20:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.569 2021/12/04 23:47:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.570 2021/12/07 23:20:09 rillig Exp $");
 
 /* types and constants */
 
@@ -2641,6 +2641,7 @@ ParseRawLine(IFile *curFile, char **out_
 	     char **out_firstBackslash, char **out_firstComment)
 {
 	char *line = curFile->buf_ptr;
+	char *buf_end = curFile->buf_end;
 	char *p = line;
 	char *line_end = line;
 	char *firstBackslash = NULL;
@@ -2652,14 +2653,14 @@ ParseRawLine(IFile *curFile, char **out_
 	for (;;) {
 		char ch;
 
-		if (p == curFile->buf_end) {
+		if (p == buf_end) {
 			res = PRLR_EOF;
 			break;
 		}
 
 		ch = *p;
 		if (ch == '\0' ||
-		    (ch == '\\' && p + 1 < curFile->buf_end && p[1] == '\0')) {
+		    (ch == '\\' && p + 1 < buf_end && p[1] == '\0')) {
 			Parse_Error(PARSE_FATAL, "Zero byte read from file");
 			return PRLR_ERROR;
 		}
@@ -2670,7 +2671,7 @@ ParseRawLine(IFile *curFile, char **out_
 				firstBackslash = p;
 			if (p[1] == '\n') {
 				curFile->lineno++;
-				if (p + 2 == curFile->buf_end) {
+				if (p + 2 == buf_end) {
 					line_end = p;
 					*line_end = '\n';
 					p += 2;
@@ -2679,7 +2680,7 @@ ParseRawLine(IFile *curFile, char **out_
 			}
 			p += 2;
 			line_end = p;
-			assert(p <= curFile->buf_end);
+			assert(p <= buf_end);
 			continue;
 		}
 

Reply via email to