diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-11-18 11:30:57 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-11-18 11:32:01 -0800 |
commit | 007b965b11b681550ee2e2244a2f53e64e88697d (patch) | |
tree | e3bff0e0d71e896ea1d954ae7715f672b247bf0e /log_browser.lua | |
parent | 5cce5115507800eeca7ba9c271e07c23473228f4 (diff) | |
download | text.love-007b965b11b681550ee2e2244a2f53e64e88697d.tar.gz |
audit all asserts
Each one should provide a message that will show up within LÖVE. Stop relying on nearby prints to the terminal. I also found some unnecessary ones. There is some potential here for performance regressions: the format() calls will trigger whether or not the assertion fails, and cause allocations. So far Lua's GC seems good enough to manage the load even with Moby Dick, even in some situations that caused issues in the past like undo.
Diffstat (limited to 'log_browser.lua')
-rw-r--r-- | log_browser.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/log_browser.lua b/log_browser.lua index 6b71da6..b6195b9 100644 --- a/log_browser.lua +++ b/log_browser.lua @@ -75,7 +75,7 @@ function table.shallowcopy(x) end function log_browser.draw(State, hide_cursor) - assert(#State.lines == #State.line_cache) + assert(#State.lines == #State.line_cache, ('line_cache is out of date; %d elements when it should be %d'):format(#State.line_cache, #State.lines)) local mouse_line_index = log_browser.line_index(State, App.mouse_x(), App.mouse_y()) local y = State.top for line_index = State.screen_top1.line,#State.lines do @@ -95,7 +95,7 @@ function log_browser.draw(State, hide_cursor) love.graphics.line(xleft,sectiony, xleft+50-2,sectiony) love.graphics.print(line.section_name, xleft+50,y) love.graphics.line(xleft+50+App.width(line.section_name)+2,sectiony, xright,sectiony) - else assert(line.section_end) + else assert(line.section_end, "log line has a section name, but it's neither the start nor end of a section") local sectiony = y+State.line_height-Section_border_padding_vertical love.graphics.line(xleft,y, xleft,sectiony) love.graphics.line(xright,y, xright,sectiony) |