summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-05 16:19:21 +0100
committerHarald Welte <laforge@gnumonks.org>2015-12-05 16:19:21 +0100
commitc696cc28d8e61a50717e3c2e68a7cfe2d08c8a48 (patch)
tree48720cfb718b652a14f2717364c010502f9bb530
parente1ba781f7b3d45b3e8f9ea87c3041e6980dcf946 (diff)
gsm_data_shared: compute/sprintf the lchan name only once
We now store the pre-printed lchan name in lchan->name to avoid having to call sprintf every time there is a debug statement somewhere, particularly as most of those debug statements are going to be inactive most of the time.
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h8
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 1b7382d..000207d 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -233,6 +233,8 @@ struct gsm_lchan {
uint8_t rqd_ta;
+ char *name;
+
#ifdef ROLE_BSC
struct osmo_timer_list T3101;
struct osmo_timer_list T3109;
@@ -759,9 +761,13 @@ const char *gsm_lchant_name(enum gsm_chan_t c);
const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
char *gsm_trx_name(const struct gsm_bts_trx *trx);
char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
-char *gsm_lchan_name(const struct gsm_lchan *lchan);
+char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
const char *gsm_lchans_name(enum gsm_lchan_state s);
+static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
+{
+ return lchan->name;
+}
void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 89d13fd..9f9eb1e 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -188,12 +188,15 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
for (l = 0; l < TS_MAX_LCHAN; l++) {
struct gsm_lchan *lchan;
+ char *name;
lchan = &ts->lchan[l];
lchan->ts = ts;
lchan->nr = l;
lchan->type = GSM_LCHAN_NONE;
+ name = gsm_lchan_name_compute(lchan);
+ lchan->name = talloc_strdup(trx, name);
#ifndef ROLE_BSC
INIT_LLIST_HEAD(&lchan->sapi_cmds);
#endif
@@ -345,7 +348,7 @@ char *gsm_ts_name(const struct gsm_bts_trx_ts *ts)
return ts2str;
}
-char *gsm_lchan_name(const struct gsm_lchan *lchan)
+char *gsm_lchan_name_compute(const struct gsm_lchan *lchan)
{
struct gsm_bts_trx_ts *ts = lchan->ts;