From 3d8605d8685749f662709a861ce579f526924fe0 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 14 May 2020 16:14:03 +0200 Subject: sccp_user_find: optimize: search PC only for valid PC arg Though, since in current practice, not many users exist, and all incoming messages have a valid PC, this is unlikely to have any noticeable effect. Change-Id: I3533a01e29b97bebe4b8f1f6965444519b3bacfe --- src/sccp_user.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sccp_user.c b/src/sccp_user.c index a36ac93..d8a7357 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -50,10 +50,12 @@ sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc) { struct osmo_sccp_user *scu; - /* First try to find match for PC + SSN */ - llist_for_each_entry(scu, &inst->users, list) { - if (osmo_ss7_pc_is_valid(scu->pc) && scu->pc == pc && scu->ssn == ssn) - return scu; + if (osmo_ss7_pc_is_valid(pc)) { + /* First try to find match for PC + SSN */ + llist_for_each_entry(scu, &inst->users, list) { + if (osmo_ss7_pc_is_valid(scu->pc) && scu->pc == pc && scu->ssn == ssn) + return scu; + } } /* Then try to match on SSN only */ -- cgit v1.2.3