pespin has uploaded this change for review.

View Change

sccp_scpc.c: Simplify conn_create()

Drop local variable with no real use, dereference sccp_instance pointer
once instead of potentially thousands of times.

Change-Id: Iee333fb38d7a37877c37c1de9719a6b67d9e8ed3
---
M src/sccp_scoc.c
1 file changed, 18 insertions(+), 7 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/26/31826/1
diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c
index 2430462..53cdf78 100644
--- a/src/sccp_scoc.c
+++ b/src/sccp_scoc.c
@@ -505,7 +505,7 @@
/* Search for next free connection ID and allocate conn */
static struct sccp_connection *conn_create(struct osmo_sccp_user *user)
{
- uint32_t conn_id;
+ struct osmo_sccp_instance *sccp = user->inst;

/* SUA: RFC3868 sec 3.10.4:
* The source reference number is a 4 octet long integer.
@@ -520,13 +520,12 @@
*/
do {
/* Optimized modulo operation (% 0x00FFFFFE) using bitwise AND plus CMP: */
- user->inst->next_id = (user->inst->next_id + 1) & 0x00FFFFFF;
- if (OSMO_UNLIKELY(user->inst->next_id == 0x00FFFFFF))
- user->inst->next_id = 0;
- conn_id = user->inst->next_id;
- } while (conn_find_by_id(user->inst, conn_id));
+ sccp->next_id = (sccp->next_id + 1) & 0x00FFFFFF;
+ if (OSMO_UNLIKELY(sccp->next_id == 0x00FFFFFF))
+ sccp->next_id = 0;
+ } while (conn_find_by_id(sccp, sccp->next_id));

- return conn_create_id(user, conn_id);
+ return conn_create_id(user, sccp->next_id);
}

static void conn_opt_data_clear_cache(struct sccp_connection *conn)

To view, visit change 31826. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Iee333fb38d7a37877c37c1de9719a6b67d9e8ed3
Gerrit-Change-Number: 31826
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange