Skip to content

Commit

Permalink
Make AddTuple() internally check HasTuple()
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Oct 19, 2023
1 parent c975ac3 commit 5cad037
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions worker/src/RTC/IceServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,8 @@ namespace RTC
}
else
{
auto* storedTuple = HasTuple(tuple);

// If a new tuple store it.
if (!storedTuple)
{
storedTuple = AddTuple(tuple);
}
// Store the tuple.
auto* storedTuple = AddTuple(tuple);

if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
{
Expand Down Expand Up @@ -464,13 +459,8 @@ namespace RTC
}
else
{
auto* storedTuple = HasTuple(tuple);

// If a new tuple store it.
if (!storedTuple)
{
storedTuple = AddTuple(tuple);
}
// Store the tuple.
auto* storedTuple = AddTuple(tuple);

if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
{
Expand Down Expand Up @@ -512,11 +502,8 @@ namespace RTC

if (!hasUseCandidate && !hasNomination)
{
// If a new tuple store it.
if (!HasTuple(tuple))
{
AddTuple(tuple);
}
// Store the tuple.
AddTuple(tuple);
}
else
{
Expand All @@ -528,13 +515,8 @@ namespace RTC
hasNomination ? "true" : "false",
nomination);

auto* storedTuple = HasTuple(tuple);

// If a new tuple store it.
if (!storedTuple)
{
storedTuple = AddTuple(tuple);
}
// Store the tuple.
auto* storedTuple = AddTuple(tuple);

if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
{
Expand Down Expand Up @@ -568,21 +550,13 @@ namespace RTC

if (!hasUseCandidate && !hasNomination)
{
// If a new tuple store it.
if (!HasTuple(tuple))
{
AddTuple(tuple);
}
// Store the tuple.
AddTuple(tuple);
}
else
{
auto* storedTuple = HasTuple(tuple);

// If a new tuple store it.
if (!storedTuple)
{
storedTuple = AddTuple(tuple);
}
// Store the tuple.
auto* storedTuple = AddTuple(tuple);

if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
{
Expand All @@ -606,10 +580,19 @@ namespace RTC
{
MS_TRACE();

auto* storedTuple = HasTuple(tuple);

if (storedTuple)
{
MS_DEBUG_DEV('tuple already exists');

return storedTuple;
}

// Add the new tuple at the beginning of the list.
this->tuples.push_front(*tuple);

auto* storedTuple = std::addressof(*this->tuples.begin());
storedTuple = std::addressof(*this->tuples.begin());

// If it is UDP then we must store the remote address (until now it is
// just a pointer that will be freed soon).
Expand Down

0 comments on commit 5cad037

Please sign in to comment.