Skip to content

Commit

Permalink
Another round of fixes, including figuring out the memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ahicks92 committed Oct 3, 2024
1 parent 822baae commit 7d8306c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion scripts/ds/deque.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A double-ended queue based on: https://www.lua.org/pil/11.4.html
That's a long resource. The idea is much simpler than the chapter: maintain two
indices for thje bottom and top, then use the fact that Lua allows "moving" the
indices for the bottom and top, then use the fact that Lua allows "moving" the
array upward forever at the cost of becoming a hashtable.
This is global-safe.
Expand Down Expand Up @@ -61,6 +61,7 @@ function Deque:pop_front()
local b = self.back
if b < f then return nil end
local r = self.items[f]
self.items[f] = nil
self.front = f + 1
return r
end
Expand All @@ -71,6 +72,7 @@ function Deque:pop_back()
local b = self.back
if b < f then return nil end
local r = self.items[b]
self.items[b] = nil
self.back = b - 1
return r
end
Expand All @@ -79,6 +81,7 @@ function Deque:clear()
self.front = 1
self.back = 0
self.items = {}
self.items = {}
end

-- Some quick self-tests.
Expand Down
2 changes: 2 additions & 0 deletions scripts/scanner/backends/trees.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ function TreeBackend:dump_entries_to_set(player, set)
end
end

self.point_queue = TH.defaulting_table()

self.clusterer:submit_points(points_flat)

local px, py = player.position.x, player.position.y
Expand Down
2 changes: 1 addition & 1 deletion scripts/scanner/surface-scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ local BACKEND_LUT = {
["straight-rail"] = SEB.TrainsSimple,
["stream"] = SEB.Other,
["tile-ghost"] = SEB.Ghosts,
["train-stop"] = SEB.TrainsNamed,
["train-stop"] = SEB.TrainsSimple,
["transport-belt"] = SEB.Logistics,
["tree"] = TreeBackend.TreeBackend,
["turret"] = SEB.Unit,
Expand Down

0 comments on commit 7d8306c

Please sign in to comment.