Closed SquidDev closed 9 years ago
I do think having a set of connections is the most efficient way of doing this. It's much better than traversing the entire network multiple times for any change, which is what vanilla CC does.
The trouble is that it is much harder to then find connections from a node, and so to send a message you end up iterating the connection map once for every node on the network - which isn't optimal.
I think that operation is rather minimal. The advantages of remembering connections as a set are fairly valuable I think
You're probably right. I'll profile everything later today to see if there are any hot spots though.
For instance, in creating new networks when a node is removed, all that needs allocating is the new network objects. The connections get to be transferred from one to the other very efficiently. And especially joining two networks is really efficient this way.
Looking at OpenComputers, they use Map<INetworkNode, Set<Connection>>
. I don't want to copy and paste their network infrastructure, but it is pretty well written.
Also, they've copied my idea of using markdown as an in-game documentation format. :frowning:.
I've profiled and it isn't an issue at all though. There could be some tiny render optimisations todo, but not a priority.
Replace set of connections with a more efficient data structure. Ideally we should be able to find connections to/from any node without having to iterate through the list. AWhilst profiling this it doesn't seem too much of a problem. It is less than ideal, but should be OK.Map<INetworkNode, Set<INetworkNode>>
would work, but it does mean a two way mapping is harder to ensure.Optimise the network code. Currently removing a node recreates the entire network. This could be happening several hundred times on a chunk unload.Not really a problem.It might also be worth considering changing the use of
getMetadata
(TileGeneric method) togetBlockMetadata
(TileEntity method) as this, and thegetBlock
equivalent implement caching.