Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Removed unneeded conditional #8

Closed

Conversation

hjerpbakk
Copy link

No description provided.

@Grinshpon
Copy link

That's not an unneeded conditional. It says if the damage value is zero the function returns zero.

@Berzeger
Copy link

Berzeger commented Jun 2, 2020

Grinshpon, the condition that follows immediately after checks for that again, so I'd say it's unnecessary.

@smbkr
Copy link

smbkr commented Jun 3, 2020

The original implementation could have been an optimisation, if the checks that follow were expensive to perform, allowing the function to return early before incurring that cost -- however this is probably irrelevant in 2020.

@hjerpbakk
Copy link
Author

This is not a performance improvement, but rather a removing of redundant code and brings this check to parity with

if (Special.IsInert || !damage || warhead == WARHEAD_NONE) return(0);

@Sgt-Nukem
Copy link

The original implementation could have been an optimisation, if the checks that follow were expensive to perform, allowing the function to return early before incurring that cost -- however this is probably irrelevant in 2020.

And even now one could get it back by simply swapping !damage to the front and early-out that way:

if ( !damage || Special.IsInert || warhead == WARHEAD_NONE ) return(0);

@LFeenanEA LFeenanEA closed this Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants