ref: 81585efedab7f9d040053211b6652368a7db6032
parent: 57fb4c212047c9e4d305a32e8def2a85721a4b37
author: mia soweli <[email protected]>
date: Thu Aug 31 10:17:15 EDT 2023
screen: refrain from copying the font getmemdefont() allocates and makes a copy. screendatainit() already saved it to ctlr->scrfont. use that instead of calling getmemdefont() for every memimagestring().
--- a/sys/src/9/n900/screen.c
+++ b/sys/src/9/n900/screen.c
@@ -150,7 +150,7 @@
r = insetrect(r, 6);
p = r.min;
- memimagestring(ctlr->scrimg, p, memblack, ZP, getmemdefont(), " Plan 9 Console ");
+ memimagestring(ctlr->scrimg, p, memblack, ZP, ctlr->scrfont, " Plan 9 Console ");
}
ctlr->win = Rpt(addpt(r.min, Pt(0, h + 6)), subpt(r.max, Pt(6, 6)));
@@ -283,7 +283,7 @@
break;
default:
- p = memsubfontwidth(getmemdefont(), buf); w = p.x;
+ p = memsubfontwidth(ctlr->scrfont, buf); w = p.x;
if(ctlr->pos.x >= ctlr->win.max.x - w)
screenputc(ctlr, "\n");
@@ -290,7 +290,7 @@
*xp++ = ctlr->pos.x;
r = Rect(ctlr->pos.x, ctlr->pos.y, ctlr->pos.x + w, ctlr->pos.y + h);
memimagedraw(ctlr->scrimg, r, memwhite, ZP, memopaque, ZP, S);
- memimagestring(ctlr->scrimg, ctlr->pos, memblack, ZP, getmemdefont(), buf);
+ memimagestring(ctlr->scrimg, ctlr->pos, memblack, ZP, ctlr->scrfont, buf);
ctlr->pos.x += w;
break;
}