Do u know that Factorio use only one core (to be precise one thread) of ur CPU to the entities processing? :)
So no multithreading-per-core ALU feature, no complete use of CPU multi-level cache, no forkjoin threads management, no master-slave threads management, no multithreading work-stealing.. also Factorio require around 1 GB of ram to work and not fast GPU but only some VRAM, and mods don't use the main language of the engine that is C++, use LUA, that is slower.
I tried variuos implementations of this code and I didn't find a way to optimize this more.
I suggest u to leave the game play until the virus die (not more than 10 minutes), if u can't really play not use the virus at all (is not mandatory use virus to play), I'm sorry but we can't optimize this more...