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 /search.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 'search.lua')
-rw-r--r-- | search.lua | 2 |
1 files changed, 1 insertions, 1 deletions
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 |