There is an unnecessary "AsciiString("NoSound") allocation at the top.
And the shouldPlayLocally test can be moved higher up for eventToAdd instead of audioEvent. This will save a bunch of calculations and allocations.
if (!eventToAdd->getUninterruptable()) {
if (!shouldPlayLocally(eventToAdd)) {
return AHSV_NotForLocal;
}
}
I already verified that this is correct by testing it together with the original code for audioEvent and see if they always return the same result, which they did.
This function is very often called for sounds that will fail to trigger, for example money deposit and withdrawal sounds for players that cannot be listened to.
There could be some benefit from making this function cheaper.
There is an unnecessary "AsciiString("NoSound") allocation at the top.
And the
shouldPlayLocallytest can be moved higher up foreventToAddinstead ofaudioEvent. This will save a bunch of calculations and allocations.I already verified that this is correct by testing it together with the original code for
audioEventand see if they always return the same result, which they did.This function is very often called for sounds that will fail to trigger, for example money deposit and withdrawal sounds for players that cannot be listened to.
There could be some benefit from making this function cheaper.