profile-guided optimization

This commit is contained in:
2025-06-23 01:37:57 -07:00
parent 5e6b98523b
commit d7e029edb6
2 changed files with 515 additions and 16 deletions

View File

@ -64,8 +64,7 @@ end
-- items for which f was false.
function stripped(list, f)
local ret, n = {}, 0
for i=1,#list do
local v = list[i]
for v in all(list) do
if not f(v) then
n += 1
ret[n] = v
@ -80,8 +79,7 @@ end
-- onto dest.
function appendmove(dest, src)
local n = #dest
for i=1, #src do
local v = src[i]
for v in all(src) do
if not v:move() then
n += 1
dest[n] = v
@ -94,8 +92,7 @@ end
-- instead of taking a func arg.
function stripmoved(list)
local ret, n = {}, 0
for i=1,#list do
local v = list[i]
for v in all(list) do
if not v:move() then
n += 1
ret[n] = v
@ -202,7 +199,7 @@ function updategame()
events = stripmoved(events)
appendmove(events, new_events)
new_events = {}
intangibles_big = stripmoved(intangibles_bg)
intangibles_bg = stripmoved(intangibles_bg)
eships = stripmoved(eships)
-- eship collider will be used
@ -223,7 +220,7 @@ function updategame()
return eb:hitship(ps)
end)
else
ebullets:stripmove()
ebullets=stripmoved(ebullets)
end
pbullets = stripped(pbullets, function(pb)
@ -234,7 +231,7 @@ function updategame()
end
end)
intangibles_fg:stripmove()
intangibles_fg = stripmoved(intangibles_fg)
if waves_complete == 32767 and #eships == 0 and #ebullets == 0 and #events == 0 then
game_state = win
@ -324,8 +321,8 @@ function drawgame()
clip(0,0,112,128)
rectfill(0,0,112,128,0)
for drawables in all{intangibles_bg, pbullets, {primary_ship}, eships, ebullets, intangibles_fg} do
for item in all(drawables) do
item:draw()
for d in all(drawables) do
d:draw()
end
end
clip(0,0,128,128)
@ -1372,9 +1369,8 @@ end
collider = mknew{
init = function(x)
local from = x.from
for k=1,#from do
for n in all(from) do
-- insert
local n = from[k]
for i in all(collider_indexes(hurtbox(n))) do
local a = x[i]
if not a then
@ -1388,11 +1384,10 @@ collider = mknew{
}
function collider_indexes(box)
local ret,i = {}, 0
local ret = {}
for x = box.x\8, (box.x+box.width)\8 do
for y = box.y\8, (box.y+box.height)\8 do
i += 1
ret[i] = x+256*y
add(ret, x+256*y)
end
end
return ret