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. --- search.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'search.lua') diff --git a/search.lua b/search.lua index fe57ac9..67b82b3 100644 --- a/search.lua +++ b/search.lua @@ -139,7 +139,7 @@ function rfind(s, pat, i, plain) local rendpos = rs:find(rpat, ri, plain) if rendpos == nil then return nil end local endpos = #s - rendpos + 1 - assert (endpos >= #pat) + assert (endpos >= #pat, ('rfind: endpos %d should be >= #pat %d at this point'):format(endpos, #pat)) return endpos-#pat+1 end -- cgit 1.4.1-2-gfad0