With 30log gone, we can add some special-purpose collection types for improved performance and ease-of-use.
PointSet is a collection of unique points, useful for replacing foo[x..','..y]=1 idiom.
Grid is just what it sounds like, useful for replacing foo[x..','..y]=someValue idiom. Also useful for replacing foo[x][y]=someValue idiom in cases where dimensions are not known beforehand. Both classes cut way back on the number of tables that need to be created, improving memory consumption and speed.
In this PR, PointSet and Grid are used in several places, making automated tests (and presumably application code) run a good bit faster, and simplifying calling code. There are other places they can be used as well.
If anyone has suggestions about the API for these two classes, as far as method names and so on, please let me know.
A quick before and after example:
-- before
for k,_ in pairs(litCells) do
local parts=k:split(',')
local x=tonumber(parts[1])
local y=tonumber(parts[2])
lightingCallback(x, y, litCells[k])
end
-- after
for _, x, y, value in litCells:each() do
lightingCallback(x, y, value)
end
Sort of related, but not really: Line and Point were made internal to Bresenham, since nothing else was using them. Can be moved back out with other custom types later if needed.
Unrelated, but included anyway, are some changes to Brogue to make it behave more like the other dungeon generators with respect to doors and rooms.
With 30log gone, we can add some special-purpose collection types for improved performance and ease-of-use.
PointSet is a collection of unique points, useful for replacing
foo[x..','..y]=1
idiom.Grid is just what it sounds like, useful for replacing
foo[x..','..y]=someValue
idiom. Also useful for replacingfoo[x][y]=someValue
idiom in cases where dimensions are not known beforehand. Both classes cut way back on the number of tables that need to be created, improving memory consumption and speed.In this PR, PointSet and Grid are used in several places, making automated tests (and presumably application code) run a good bit faster, and simplifying calling code. There are other places they can be used as well.
If anyone has suggestions about the API for these two classes, as far as method names and so on, please let me know.
A quick before and after example:
Sort of related, but not really: Line and Point were made internal to Bresenham, since nothing else was using them. Can be moved back out with other custom types later if needed.
Unrelated, but included anyway, are some changes to Brogue to make it behave more like the other dungeon generators with respect to doors and rooms.