The biggest saving i found was by replacing Structure.prototype.isActive
const _isActive = Structure.prototype.isActive;
Structure.prototype.isActive = function() {
if (this.structureType === STRUCTURE_CONTAINER || this.structureType === STRUCTURE_ROAD) {
// Always true for these
this.isActive = function() { return true };
return true;
}
const room = this.room;
const roomLevel = (room.memory.level || room.controller.level);
if (roomLevel === CONTROLLER_MAX_LEVEL) {
this.isActive = function() { return true };
return true;
}
const curActive = _isActive.call(this);
this.isActive = function() { return curActive };
return curActive;
};