Leaves a note re: improving render speeds

This commit is contained in:
sloum 2020-02-13 22:46:39 -08:00
parent c9765bf0fa
commit 996e209c50
2 changed files with 14 additions and 0 deletions

View File

@ -1024,6 +1024,10 @@ func (c *client) handleLocal(u Url) {
return
}
pg := MakePage(u, content, links)
ext := strings.ToLower(filepath.Ext(u.Full))
if ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png" {
pg.FileType = "image"
}
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
c.PageState.Add(pg)
c.SetPercentRead()

View File

@ -66,7 +66,17 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
}
pos := p.History[p.Position].ScrollPosition
prev := len(p.History[p.Position].WrappedContent)
// TODO figure out a way to only do this when needed
// it is horribly slow to do this every render.
//
// Current thought is add a "WrapWidth" to each page
// and compare the WrapWidth against the width being
// passed in here. If it is different then go through
// all of that. Otherwise, just send the already wrapped
// data.
p.History[p.Position].WrapContent(termWidth, color)
now := len(p.History[p.Position].WrappedContent)
if prev > now {
diff := prev - now