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
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 1819b5b..5edf9ff 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -115,17 +115,12 @@
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++) {