gbranden pushed a commit to branch master
in repository groff.
commit cb28f70fd21c45eb60b1892ba4f694560618662f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Mar 21 11:23:11 2026 -0500
src/roff/troff/input.cpp: Slightly refactor (2/3).
* src/roff/troff/input.cpp (substring_request): Introduce new local
variable `len` to store value of `len` `macro` object being operated
on, it case the compiler isn't smart enough to cache a repeated member
variable access itself.
---
ChangeLog | 8 ++++++++
src/roff/troff/input.cpp | 11 ++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 90e53deec..b695afeab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-03-21 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (substring_request): Slightly
+ refactor. Introduce new local variable `len` to store value of
+ `len` `macro` object being operated on, it case the compiler
+ isn't smart enough to cache a repeated member variable access
+ itself.
+
2026-03-21 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (substring_request): Slightly
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 3e03e48d7..06d5eb026 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5810,17 +5810,18 @@ void substring_request()
else {
int end = -1;
if (!has_arg() || read_integer(&end)) {
+ int len = m->len;
string_iterator iter1(*m);
// We don't apply substring operations to internally generated
// tokens that manage compatibility mode.
int operable_length = 0;
- for (int l = 0; l < m->len; l++) {
+ for (int l = 0; l < len; l++) {
int c = iter1.get(0 /* nullptr */);
if ((PUSH_GROFF_MODE == c)
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
continue;
- if (l == m->len)
+ if (l == len)
break;
operable_length++;
}
@@ -5836,7 +5837,7 @@ void substring_request()
if ((start >= operable_length) || (end < 0)) {
warning(WARN_RANGE,
"start and end index of substring out of range");
- m->len = 0;
+ len = m->len = 0;
if (m->p != 0 /* nullptr */) {
if (--(m->p->count) <= 0)
delete m->p;
@@ -5865,7 +5866,7 @@ void substring_request()
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
c = iter.get(0 /* nullptr */);
- if (i == m->len)
+ if (i == len)
break;
}
macro mac;
@@ -5876,7 +5877,7 @@ void substring_request()
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
c = iter.get(0 /* nullptr */);
- if (i == m->len)
+ if (i == len)
break;
if (0U == c)
mac.append(nd);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit