Skip to content

Optimize AudioManager::addAudioEvent() #1352

@xezon

Description

@xezon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AudioIs audio relatedInvestigateMinorSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concern

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions