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.
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 @@
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 @@
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;