I am trying to optimize an IJobEntity job that handles adding/removing status effects. It looks somewhat like this:
public partial struct StatusEffectRequestJob : IJobEntity
{
void Execute(Entity entity, ref DynamicBuffer<StatusEffectRequests> statusEffectRequests)
{
for (int i = statusEffectRequests.Length - 1; i >= 0; i--)
{
// Evaluate request...
statusEffectRequests.RemoveAt(i);
}
}
}
The idea is that when I want to add or remove a status effect I can just add the request onto the entity and then a system schedules this job each update. The issue is that regardless of whether or not there are actually any requests in the buffer, it calls execute. This may be just a micro-optimization but is there a way to have it only Execute() when the DynamicBuffer actually contains a length > 0?