Blob Blame History Raw
From 332262ec91f85cd4224816d2803d818015239007 Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Wed, 29 Jun 2022 09:18:15 +0100
Subject: [PATCH] parser: optimise fixing recalculating updated line length

Commit 1ffad9a - "recalculate buffer length inside recheck loop"
resolved the issue but calls strlen(buf) more often than necessary.

This commit only calls strlen(buf) when the line buffer is modified.

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 lib/parser.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/parser.c b/lib/parser.c
index bcabd07f..2146f38b 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -2809,6 +2809,9 @@ read_line(char *buf, size_t size)
 					recheck = true;
 				if (strchr(buf, '$'))
 					recheck = true;
+
+				if (recheck)
+					len = strlen(buf);
 			}
 		} while (recheck);
 	} while (buf[0] == '\0' || check_include(buf));
-- 
2.38.1