Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup of Hearing module #2146

Merged
merged 4 commits into from
Aug 30, 2015
Merged

Code cleanup of Hearing module #2146

merged 4 commits into from
Aug 30, 2015

Conversation

jokoho48
Copy link
Member

Code cleanup of Hearing module.

@PabstMirror PabstMirror added the kind/cleanup Release Notes: **CHANGED:** label Aug 13, 2015
@PabstMirror PabstMirror added this to the 3.3.0 milestone Aug 13, 2015
case (handgunWeapon _firer) : {(handgunItems _firer) select 0};
default {""};
_silencer = call {
if (primaryWeapon _firer) exitWith {(primaryWeaponItems _firer) select 0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a string inside of a if statement and no comparison to _weapon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah i miss that

@PabstMirror
Copy link
Contributor

I tested the call/switch statements, I'm not seeing much benifit in bis's benchmark:

_firer = player;
_weapon = (handgunWeapon player);
_silencer = switch (_weapon) do {
    case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0};
    case (secondaryWeapon _firer) : {(secondaryWeaponItems _firer) select 0};
    case (handgunWeapon _firer) : {(handgunItems _firer) select 0};
    default {""};
};
0.0117188 ms
0.0116699 ms

_firer = player;
_weapon = (handgunWeapon player);
_silencer = call {
    if ((primaryWeapon _firer) == _weapon) exitWith {(primaryWeaponItems _firer) select 0};
    if ((secondaryWeapon _firer) == _weapon) exitWith {(secondaryWeaponItems _firer) select 0};
    if ((handgunWeapon _firer) == _weapon) exitWith {(handgunItems _firer) select 0};
    ""
};
0.012207 ms
0.0123047 ms

@jokoho48
Copy link
Member Author

yeah right see what you mean hmm ok i try it self

@thojkooi
Copy link
Contributor

In fact looking at those tests, it seems to be faster to stick with the switch. It also is easier to read/understand without having to take a closer look imo.

@jokoho48
Copy link
Member Author

but if you use a swtich True call if exitWith is faster

@thojkooi thojkooi modified the milestones: 3.3.0, 3.4.0 Aug 29, 2015
@PabstMirror PabstMirror modified the milestones: 3.3.0, 3.4.0 Aug 30, 2015
PabstMirror added a commit that referenced this pull request Aug 30, 2015
@PabstMirror PabstMirror merged commit 2f54cfa into acemod:master Aug 30, 2015
@PabstMirror
Copy link
Contributor

looks good, merging before looking at #1988 to avoid conflicts.

@jokoho48 jokoho48 deleted the codeCleanupHearing branch August 30, 2015 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Release Notes: **CHANGED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants