Skip to content

Add NotifyTargetSet#1251

Merged
Jamiras merged 14 commits into
RetroAchievements:masterfrom
Jamiras:feature/notify_target_set
Oct 31, 2025
Merged

Add NotifyTargetSet#1251
Jamiras merged 14 commits into
RetroAchievements:masterfrom
Jamiras:feature/notify_target_set

Conversation

@Jamiras
Copy link
Copy Markdown
Member

@Jamiras Jamiras commented Oct 25, 2025

Replaces the common pattern of:

    NotifyTargetSet vNotifyTargets(m_vNotifyTargets);
    for (NotifyTarget* target : vNotifyTargets)
    {
        Expects(target != nullptr);
        target->OnDataModelBoolValueChanged(args);
    }

with

    if (m_vNotifyTargets.LockIfNotEmpty())
    {
        for (auto& target : m_vNotifyTargets.Targets())
            target.OnDataModelBoolValueChanged(args);

        m_vNotifyTargets.Unlock();
    }

Which provides three small performance boosts:

  1. Avoids the copy/iterate if the list is empty
  2. Avoids the copy entirely unless the list is modified while it is locked
  3. Avoids the null check inside the for loop

None of these are very expensive by themselves, but ever PropertyChanged event uses this construct to propogate the event to the handlers. And those may chain into other handlers and additional PropertyChanged events.

This shaves roughly a dozen microseconds off each frame.

@Jamiras Jamiras added this to the 1.4.1 milestone Oct 25, 2025
@Jamiras Jamiras merged commit 966e27d into RetroAchievements:master Oct 31, 2025
6 checks passed
@Jamiras Jamiras deleted the feature/notify_target_set branch October 31, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant