From 007b965b11b681550ee2e2244a2f53e64e88697d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 18 Nov 2023 11:30:57 -0800 Subject: audit all asserts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- log_browser.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'log_browser.lua') 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) -- cgit 1.4.1-2-gfad0