<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7242">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  Corey Farrell: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Use sorcery prefix operation for contact lookup<br><br>This improves performance for registrations assuming that<br>res_config_astdb is not in use.<br><br>Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1<br>---<br>M res/res_pjsip/location.c<br>1 file changed, 10 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c<br>index 8ba409e..2bd40e8 100644<br>--- a/res/res_pjsip/location.c<br>+++ b/res/res_pjsip/location.c<br>@@ -71,16 +71,17 @@<br> {<br>   const struct ast_sip_aor *aor = object;<br>       const char *aor_id = ast_sorcery_object_get_id(object);<br>-      /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */<br>-     char regex[strlen(aor_id) + 4];<br>+      /* Give enough space for ;@ at the end, since that is our object naming scheme */<br>+    size_t prefix_len = strlen(aor_id) + sizeof(";@") - 1;<br>+     char prefix[prefix_len + 1];<br>  struct ao2_container *contacts;<br> <br>    if (aor->permanent_contacts) {<br>             ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL);<br>      }<br> <br>- snprintf(regex, sizeof(regex), "^%s;@", aor_id);<br>-   if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {<br>+        sprintf(prefix, "%s;@", aor_id); /* Safe */<br>+        if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {<br>           return;<br>       }<br>     /* Destroy any contacts that may still exist that were made for this AoR */<br>@@ -217,13 +218,13 @@<br> struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor,<br>      unsigned int flags)<br> {<br>-      /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */<br>-     char regex[strlen(ast_sorcery_object_get_id(aor)) + 4];<br>+      /* Give enough space for ;@ at the end, since that is our object naming scheme */<br>+    size_t prefix_len = strlen(ast_sorcery_object_get_id(aor)) + sizeof(";@") - 1;<br>+     char prefix[prefix_len + 1];<br>  struct ao2_container *contacts;<br> <br>-   snprintf(regex, sizeof(regex), "^%s;@", ast_sorcery_object_get_id(aor));<br>-<br>-        if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {<br>+        sprintf(prefix, "%s;@", ast_sorcery_object_get_id(aor)); /* Safe */<br>+        if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {<br>           return NULL;<br>  }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7242">change 7242</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7242"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1 </div>
<div style="display:none"> Gerrit-Change-Number: 7242 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>