jcs
/textview
/amendments
/76
TVInvertRange: Avoid having to call TVXForOffset if we don't have to
jcs made amendment 76 about 1 month ago
--- tv_draw.c Wed Oct 14 21:51:20 2026
+++ tv_draw.c Wed Oct 14 22:38:35 2026
@@ -599,10 +599,18 @@ TVInvertRange(struct TVRec *tv, unsigned long a, unsig
if (!chars && !trail)
continue;
- left = TVXForOffset(tv, line, a > line->start ? a : line->start);
- right = TVXForOffset(tv, line, b < line->end ? b : line->end);
+ if (a <= line->start)
+ left = line->rect.left + line->indent;
+ else
+ left = TVXForOffset(tv, line, a);
+
+ if (b >= line->end)
+ right = line->rect.right + line->indent;
+ else
+ right = TVXForOffset(tv, line, b);
if (trail && right < edge)
right = edge;
+
if (right <= left)
continue;