jcs
/textview
/amendments
/83
TVUpdateScrollbar+TVScroll: Cache TVScrollDivisor result
jcs made amendment 83 about 1 month ago
--- textview.c Thu Oct 15 08:54:04 2026
+++ textview.c Thu Oct 15 08:56:59 2026
@@ -487,7 +487,6 @@ TVAppendLocked(struct TVRec *tv, struct TVStyle *style
BigRect redraw;
Rect r;
unsigned long avail, wastop, fromend;
- short width;
TVSlabLocator prev_style, prev_chunk_loc;
char *text_slab_data;
Boolean new_chunk;
--- tv_draw.c Wed Oct 14 23:12:03 2026
+++ tv_draw.c Thu Oct 15 08:58:41 2026
@@ -25,9 +25,10 @@ TVUpdateScrollbar(TVHandle tvh, ControlHandle scroller
struct TVRec *tv;
long max;
RgnHandle rgn;
- short wasval, wasmax, val;
+ short wasval, wasmax, val, div;
tv = TVLock(tvh);
+ div = TVScrollDivisor(tv);
/*
* Avoid SetCtlMin/Max because it will redraw and then SetCtlValue will
@@ -35,7 +36,7 @@ TVUpdateScrollbar(TVHandle tvh, ControlHandle scroller
* scrollbar position in the same place (like at the bottom).
*/
max = (tv->bounds.bottom - tv->bounds.top -
- (tv->view.bottom - tv->view.top)) / TVScrollDivisor(tv);
+ (tv->view.bottom - tv->view.top)) / div;
if (max < 0)
max = 0;
@@ -44,7 +45,7 @@ TVUpdateScrollbar(TVHandle tvh, ControlHandle scroller
HLock(scroller);
wasmax = (*scroller)->contrlMax;
(*scroller)->contrlMin = 0;
- val = -(tv->scrolled.top) / TVScrollDivisor(tv);
+ val = -(tv->scrolled.top) / div;
(*scroller)->contrlMax = max;
SetCtlValue(scroller, val);
HUnlock(scroller);
@@ -172,10 +173,11 @@ void
TVScroll(TVHandle tvh, long horiz, long vert)
{
struct TVRec *tv;
+ short div;
tv = TVLock(tvh);
- TVScrollUnlocked(tv, horiz * TVScrollDivisor(tv),
- vert * TVScrollDivisor(tv));
+ div = TVScrollDivisor(tv);
+ TVScrollUnlocked(tv, horiz * div, vert * div);
TVUnlock(tv);
}