diff options
author | Chris Robinson <[email protected]> | 2022-06-18 14:43:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-06-18 14:43:58 -0700 |
commit | 5cff007d339ce95edf0f08efacf492221ecc4f0f (patch) | |
tree | 0b83a77830293216ae2ade626636fd208ccb87bd /al | |
parent | 97ab1afa35440e74dc775ccb88e454cedd2b532c (diff) |
Avoid a full struct compare to check for changes
Diffstat (limited to 'al')
-rw-r--r-- | al/source.cpp | 25 | ||||
-rw-r--r-- | al/source.h | 4 |
2 files changed, 19 insertions, 10 deletions
diff --git a/al/source.cpp b/al/source.cpp index 2f75678c..ba622c66 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -4475,12 +4475,13 @@ void ALsource::eax5_set(const EaxCall& call, Eax5Props& props) void ALsource::eax_set(const EaxCall& call) { - switch (call.get_version()) { + switch(call.get_version()) + { case 1: eax1_set(call, eax1_.d); break; - case 2: eax2_set(call, eax2_.d); break; - case 3: eax3_set(call, eax3_.d); break; - case 4: eax4_set(call, eax4_.d); break; - case 5: eax5_set(call, eax5_.d); break; + case 2: eax2_set(call, eax2_.d); eax2_.changed = true; break; + case 3: eax3_set(call, eax3_.d); eax3_.changed = true; break; + case 4: eax4_set(call, eax4_.d); eax4_.changed = true; break; + case 5: eax5_set(call, eax5_.d); eax5_.changed = true; break; default: eax_fail_unknown_property_id(); } } @@ -4904,36 +4905,40 @@ void ALsource::eax_commit(EaxCommitType commit_type) switch (eax_version_) { case 1: - if (!is_forced && eax1_.i == eax1_.d) + if(!is_forced && eax1_.i == eax1_.d) return; eax1_.i = eax1_.d; eax1_translate(eax1_.i, eax_); break; case 2: - if (!is_forced && eax2_.i == eax2_.d) + if(!is_forced && eax2_.changed) return; + eax2_.changed = false; eax2_.i = eax2_.d; eax2_translate(eax2_.i, eax_); break; case 3: - if (!is_forced && eax3_.i == eax3_.d) + if(!is_forced && eax3_.changed) return; + eax3_.changed = false; eax3_.i = eax3_.d; eax3_translate(eax3_.i, eax_); break; case 4: - if (!is_forced && eax4_.i == eax4_.d) + if(!is_forced && eax4_.changed) return; + eax4_.changed = false; eax4_.i = eax4_.d; eax4_translate(eax4_.i, eax_); break; case 5: - if (!is_forced && eax5_.i == eax5_.d) + if(!is_forced && eax5_.changed) return; + eax5_.changed = false; eax5_.i = eax5_.d; eax_ = eax5_.d; break; diff --git a/al/source.h b/al/source.h index 5e88a7b3..850ce64f 100644 --- a/al/source.h +++ b/al/source.h @@ -207,6 +207,7 @@ private: using Eax2Props = EAX20BUFFERPROPERTIES; struct Eax2State { + bool changed{false}; Eax2Props i; // Immediate. Eax2Props d; // Deferred. }; @@ -214,6 +215,7 @@ private: using Eax3Props = EAX30SOURCEPROPERTIES; struct Eax3State { + bool changed{false}; Eax3Props i; // Immediate. Eax3Props d; // Deferred. }; @@ -230,6 +232,7 @@ private: }; struct Eax4State { + bool changed{false}; Eax4Props i; // Immediate. Eax4Props d; // Deferred. }; @@ -247,6 +250,7 @@ private: }; struct Eax5State { + bool changed{false}; Eax5Props i; // Immediate. Eax5Props d; // Deferred. }; |