add various optimizations
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
|
||||
local ffi = FFI
|
||||
|
||||
Group = {}
|
||||
|
||||
function Group.new()
|
||||
local o = {
|
||||
--state = ffi.new("long long", 0),
|
||||
state = 0,
|
||||
--state_num = ffi.new("long long", 0),
|
||||
state_num = 0,
|
||||
--in_queue = ffi.new("bool", false),
|
||||
--in_queue = false,
|
||||
--in_queue = ffi.new("long long", 0),
|
||||
in_queue = 0,
|
||||
gates_update = {},
|
||||
num_gates_update = 0,
|
||||
|
||||
fxstate = 0,
|
||||
update_tick = 0,
|
||||
|
||||
wires = {},
|
||||
out_ports = {},
|
||||
in_ports = {},
|
||||
gates_update = {},
|
||||
|
||||
state_num = 0,
|
||||
in_queue = false,
|
||||
|
||||
nwires = 0,
|
||||
nout_ports = 0,
|
||||
nin_ports = 0,
|
||||
@@ -178,7 +186,10 @@ function Group.setstate(group, state)
|
||||
group.state = state
|
||||
group.update_tick = sim.current_tick
|
||||
|
||||
for k, gate in ipairs(group.gates_update) do
|
||||
--for k, gate in ipairs(group.gates_update) do
|
||||
local len = group.num_gates_update
|
||||
for i = 1, len do
|
||||
local gate = group.gates_update[i]
|
||||
Simulation.queuegate(sim, gate)
|
||||
end
|
||||
|
||||
@@ -192,9 +203,11 @@ end
|
||||
|
||||
function Group.rebuild_ports(group)
|
||||
group.gates_update = {}
|
||||
group.num_gates_update = 0
|
||||
for k, port in pairs(group.in_ports) do
|
||||
if port.causeupdate then
|
||||
array_add(group.gates_update, Port.getgate(port))
|
||||
group.num_gates_update = group.num_gates_update + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user