From 9e0cd4ad4cde0296350e5b0440ab6e6424dc1262 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 15 Aug 2022 15:45:02 -0700 Subject: stop confusingly reading a global The way Text.draw is called by edit.draw, we know it'll never be called for lines above screen_top1.line. Comparing every line on screen with screen_top1 makes no sense. The intent is really just to compare with screen_top1 only for the first line, and otherwise to ignore this check. --- text.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'text.lua') diff --git a/text.lua b/text.lua index 3d70f93..bcecf7b 100644 --- a/text.lua +++ b/text.lua @@ -17,7 +17,7 @@ function Text.draw(State, line_index, y, startpos) -- wrap long lines local x = State.left local pos = 1 - local screen_line_starting_pos = State.screen_top1.pos + local screen_line_starting_pos = startpos if line_cache.fragments == nil then Text.compute_fragments(State, line_index) end @@ -26,7 +26,7 @@ function Text.draw(State, line_index, y, startpos) local frag, frag_text = f.data, f.text local frag_len = utf8.len(frag) --? print('text.draw:', frag, 'at', line_index,pos, 'after', x,y) - if Text.lt1({line=line_index, pos=pos}, State.screen_top1) then + if pos < startpos then -- render nothing --? print('skipping', frag) else -- cgit 1.4.1-2-gfad0 From 333a0318d98866b6d34fc51f3eddb970457da1a5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 15 Aug 2022 15:48:44 -0700 Subject: drop some unnecessary calls --- text.lua | 6 ------ 1 file changed, 6 deletions(-) (limited to 'text.lua') diff --git a/text.lua b/text.lua index bcecf7b..27849bd 100644 --- a/text.lua +++ b/text.lua @@ -18,9 +18,6 @@ function Text.draw(State, line_index, y, startpos) local x = State.left local pos = 1 local screen_line_starting_pos = startpos - if line_cache.fragments == nil then - Text.compute_fragments(State, line_index) - end Text.populate_screen_line_starting_pos(State, line_index) for _, f in ipairs(line_cache.fragments) do local frag, frag_text = f.data, f.text @@ -704,9 +701,6 @@ end function Text.to_pos_on_line(State, line_index, mx, my) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] - if line_cache.fragments == nil then - Text.compute_fragments(State, line_index) - end assert(my >= line_cache.starty) -- duplicate some logic from Text.draw local y = line_cache.starty -- cgit 1.4.1-2-gfad0