aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-30 14:34:24 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-07 10:35:28 +0200
commit20b7ba75017a590294dcd4e38135293f33f66740 (patch)
tree8e3323abb13ba5aa63632b227226d10724e32c0c
parentcc9358f95aca618db451faf53971c45dfe0b505a (diff)
alloc: Optimize find_free_usf
According to callgrind, this function consumes 33% CPU when running the AllocTest program. This commit uses the assigned_usf() method to get the USFs allocated by a PDCH instead of traversing the TBFs. Sponsored-by: On-Waves ehf
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 1819b5b5..5edf9ffa 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -115,17 +115,12 @@ static bool test_and_set_bit(uint32_t *bits, size_t elem)
static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch)
{
- struct gprs_rlcmac_ul_tbf *tbf;
uint8_t usf_map = 0;
- uint8_t tfi, usf;
+ uint8_t usf;
- /* make map of used USF */
- for (tfi = 0; tfi < 32; tfi++) {
- tbf = pdch->ul_tbf_by_tfi(tfi);
- if (!tbf)
- continue;
- usf_map |= (1 << tbf->m_usf[pdch->ts_no]);
- }
+ usf_map = pdch->assigned_usf();
+ if (usf_map == (1 << 7) - 1)
+ return -1;
/* look for USF, don't use USF=7 */
for (usf = 0; usf < 7; usf++) {