[reSIProcate] Unnecessary loop in TransportSelector.cxx

Karlsson boost.regex at gmail.com
Tue Sep 25 23:22:37 CDT 2018


In TransportSelector::transmit, I think below loop can be removed:

         if (msg->exists(h_Contacts) && msg->header(h_Contacts).size()==1)
         {
// This loop can be removed since we already detected the contact size is
1, simply use front of the contacts list is enough, don't know how to send
the PR on github.

            for (NameAddrs::iterator i=msg->header(h_Contacts).begin(); i
!= msg->header(h_Contacts).end(); i++)
            {
               const NameAddr& c_contact = *i;
               NameAddr& contact = *i;
               // No host specified, so use the ip address and port of the
               // transport used. Otherwise, leave it as is.
               if (c_contact.uri().host().empty())
               {
                  contact.uri().host() = (transport->hasSpecificContact() ?
                                          transport->interfaceName() :
                                          Tuple::inet_ntop(source) );
                  contact.uri().port() = transport->port();

                  if (transport->transport() != UDP &&
!contact.uri().exists(p_gr))
                  {
                     contact.uri().param(p_transport) =
Tuple::toDataLower(transport->transport());
                  }

                  // Add comp=sigcomp to contact URI
                  // Also, If no +sip.instance on contact HEADER,
                  // add sigcomp-id="<urn>" to contact URI.
                  if (mCompression.isEnabled())
                  {
                     if (!contact.uri().exists(p_comp))
                     {
                        contact.uri().param(p_comp) = "sigcomp";
                     }
                     if (!contact.exists(p_Instance) &&
                         !contact.uri().exists(p_sigcompId))
                     {
                        contact.uri().param(p_sigcompId) =
mCompression.getSigcompId();
                     }
                  }
               }
               else
               {
                  if (c_contact.uri().exists(p_addTransport))
                  {
                     if (target.getType() != UDP)
                     {
                        contact.uri().param(p_transport) =
Tuple::toDataLower(target.getType());
                     }
                     contact.uri().remove(p_addTransport);
                  }
               }
            }
         }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20180926/79a45c19/attachment.htm>


More information about the resiprocate-devel mailing list