[PATCH 2/2] Avoid copy constructor in uplink tbf path

Bhargava Abhyankar Bhargava.Abhyankar at radisys.com
Tue Mar 22 13:12:31 UTC 2016


The copy constructor of GprsCodingScheme class object used in
uplink tbf path is replaced by the reference variable.
Appropriate function prototypes and function definition are
changed.
This patch will increase efficiency of the code.
---
 src/bts.cpp                |  4 ++--
 src/bts.h                  |  4 ++--
 src/decoding.cpp           |  4 ++--
 src/decoding.h             |  4 ++--
 src/gprs_coding_scheme.cpp |  4 ++--
 src/gprs_coding_scheme.h   | 24 ++++++++++++------------
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/bts.cpp b/src/bts.cpp
index 715fb51..412d502 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1316,7 +1316,7 @@ int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
 }
 
 int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint32_t fn,
-	struct pcu_l1_meas *meas, GprsCodingScheme cs)
+	struct pcu_l1_meas *meas, const GprsCodingScheme &cs)
 {
 	int rc;
 	struct gprs_rlc_data_info rlc_dec;
@@ -1375,7 +1375,7 @@ int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint32_t fn,
 }
 
 int gprs_rlcmac_pdch::rcv_block_gprs(uint8_t *data, uint32_t fn,
-	struct pcu_l1_meas *meas, GprsCodingScheme cs)
+	struct pcu_l1_meas *meas, const GprsCodingScheme &cs)
 {
 	unsigned payload = data[0] >> 6;
 	bitvec *block;
diff --git a/src/bts.h b/src/bts.h
index c975304..812419e 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -66,9 +66,9 @@ struct gprs_rlcmac_pdch {
 	int rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
 		struct pcu_l1_meas *meas);
 	int rcv_block_gprs(uint8_t *data, uint32_t fn,
-		struct pcu_l1_meas *meas, GprsCodingScheme cs);
+		struct pcu_l1_meas *meas, const GprsCodingScheme &cs);
 	int rcv_data_block(uint8_t *data, uint32_t fn,
-		struct pcu_l1_meas *meas, GprsCodingScheme cs);
+		struct pcu_l1_meas *meas, const GprsCodingScheme &cs);
 
 	gprs_rlcmac_bts *bts_data() const;
 	BTS *bts() const;
diff --git a/src/decoding.cpp b/src/decoding.cpp
index 0c81b2a..1c94b5e 100644
--- a/src/decoding.cpp
+++ b/src/decoding.cpp
@@ -181,7 +181,7 @@ static int parse_extensions_gprs(const uint8_t *data, unsigned int data_len,
 }
 
 int Decoding::rlc_data_from_ul_data(
-	const struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs,
+	const struct gprs_rlc_data_block_info *rdbi, const GprsCodingScheme &cs,
 	const uint8_t *data, RlcData *chunks, unsigned int chunks_size,
 	uint32_t *tlli)
 {
@@ -342,7 +342,7 @@ void Decoding::extract_rbb(const struct bitvec *rbb, char *show_rbb)
 }
 
 int Decoding::rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
-	const uint8_t *data, GprsCodingScheme cs)
+	const uint8_t *data, const GprsCodingScheme &cs)
 {
 	unsigned int cur_bit = 0;
 	switch(cs.headerTypeData()) {
diff --git a/src/decoding.h b/src/decoding.h
index 1043d67..efee4d2 100644
--- a/src/decoding.h
+++ b/src/decoding.h
@@ -36,7 +36,7 @@ public:
 
 	static int rlc_data_from_ul_data(
 		const struct gprs_rlc_data_block_info *rdbi,
-		GprsCodingScheme cs, const uint8_t *data, RlcData *chunks,
+		const GprsCodingScheme &cs, const uint8_t *data, RlcData *chunks,
 		unsigned int chunks_size, uint32_t *tlli);
 	static uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
 	static uint8_t get_egprs_ms_class_by_capability(MS_Radio_Access_capability_t *cap);
@@ -52,7 +52,7 @@ public:
 		const uint8_t *data,
 		const GprsCodingScheme &cs);
 	static int rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
-		const uint8_t *data, GprsCodingScheme cs);
+		const uint8_t *data, const GprsCodingScheme &cs);
 	static unsigned int rlc_copy_to_aligned_buffer(
 		const struct gprs_rlc_data_info *rlc,
 		unsigned int data_block_idx,
diff --git a/src/gprs_coding_scheme.cpp b/src/gprs_coding_scheme.cpp
index 8601d4f..cb141c1 100644
--- a/src/gprs_coding_scheme.cpp
+++ b/src/gprs_coding_scheme.cpp
@@ -259,7 +259,7 @@ const char *GprsCodingScheme::modeName(Mode mode)
 	}
 }
 
-bool GprsCodingScheme::isFamilyCompatible(GprsCodingScheme o) const
+bool GprsCodingScheme::isFamilyCompatible(const GprsCodingScheme &o) const
 {
 	if (*this == o)
 		return true;
@@ -270,7 +270,7 @@ bool GprsCodingScheme::isFamilyCompatible(GprsCodingScheme o) const
 	return family() == o.family();
 }
 
-bool GprsCodingScheme::isCombinable(GprsCodingScheme o) const
+bool GprsCodingScheme::isCombinable(const GprsCodingScheme &o) const
 {
 	return numDataBlocks() == o.numDataBlocks();
 }
diff --git a/src/gprs_coding_scheme.h b/src/gprs_coding_scheme.h
index aec3762..1519e12 100644
--- a/src/gprs_coding_scheme.h
+++ b/src/gprs_coding_scheme.h
@@ -64,16 +64,16 @@ public:
 	unsigned int to_num() const;
 
 	GprsCodingScheme& operator =(Scheme s);
-	GprsCodingScheme& operator =(GprsCodingScheme o);
+	GprsCodingScheme& operator =(const GprsCodingScheme &o);
 
 	bool isValid()   const {return UNKNOWN <= m_scheme && m_scheme <= MCS9;}
 	bool isGprs()   const {return CS1 <= m_scheme && m_scheme <= CS4;}
 	bool isEgprs()  const {return m_scheme >= MCS1;}
 	bool isEgprsGmsk()  const {return isEgprs() && m_scheme <= MCS4;}
 	bool isCompatible(Mode mode) const;
-	bool isCompatible(GprsCodingScheme o) const;
-	bool isFamilyCompatible(GprsCodingScheme o) const;
-	bool isCombinable(GprsCodingScheme o) const;
+	bool isCompatible(const GprsCodingScheme &o) const;
+	bool isFamilyCompatible(const GprsCodingScheme &o) const;
+	bool isCombinable(const GprsCodingScheme &o) const;
 
 	void inc(Mode mode);
 	void dec(Mode mode);
@@ -133,7 +133,7 @@ inline bool GprsCodingScheme::isCompatible(Mode mode) const
 	return false;
 }
 
-inline bool GprsCodingScheme::isCompatible(GprsCodingScheme o) const
+inline bool GprsCodingScheme::isCompatible(const GprsCodingScheme &o) const
 {
 	return (isGprs() && o.isGprs()) || (isEgprs() && o.isEgprs());
 }
@@ -160,7 +160,7 @@ inline GprsCodingScheme& GprsCodingScheme::operator =(Scheme s)
 	return *this;
 }
 
-inline GprsCodingScheme& GprsCodingScheme::operator =(GprsCodingScheme o)
+inline GprsCodingScheme& GprsCodingScheme::operator =(const GprsCodingScheme &o)
 {
 	m_scheme = o.m_scheme;
 	return *this;
@@ -183,33 +183,33 @@ inline GprsCodingScheme GprsCodingScheme::getEgprsByNum(unsigned num)
 }
 
 /* The coding schemes form a partial ordering */
-inline bool operator ==(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator ==(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return GprsCodingScheme::Scheme(a) == GprsCodingScheme::Scheme(b);
 }
 
-inline bool operator !=(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator !=(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return !(a == b);
 }
 
-inline bool operator <(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator <(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return a.isCompatible(b) &&
 		GprsCodingScheme::Scheme(a) < GprsCodingScheme::Scheme(b);
 }
 
-inline bool operator >(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator >(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return b < a;
 }
 
-inline bool operator <=(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator <=(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return a == b || a < b;
 }
 
-inline bool operator >=(GprsCodingScheme a, GprsCodingScheme b)
+inline bool operator >=(const GprsCodingScheme &a, const GprsCodingScheme &b)
 {
 	return a == b || a > b;
 }
-- 
2.5.0




More information about the osmocom-net-gprs mailing list