Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions messaging/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ void NotifyListenerOnRegistrationReceived(const char* installationId) {
return;
}
MutexLock lock(g_listener_lock);
if (g_prev_registration_received &&
*g_prev_registration_received == installationId) {
return;
}

if (!g_prev_registration_received)
g_prev_registration_received = new std::string;
*g_prev_registration_received = installationId;
Comment on lines 175 to 177

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since we want to allow sending the registration notification even if it is the same as the previous one, we can still optimize the string assignment. If g_prev_registration_received already contains the same installationId, we can skip the redundant string copy/assignment while still proceeding to notify the listener.

  if (!g_prev_registration_received) {
    g_prev_registration_received = new std::string(installationId);
  } else if (*g_prev_registration_received != installationId) {
    *g_prev_registration_received = installationId;
  }

Expand Down
Loading