wifi: Access structures with const references to prevent copies

This commit is contained in:
Gabriel Ferreira
2022-01-08 15:54:08 -03:00
parent 6f3639f4cd
commit f367474ca3
2 changed files with 9 additions and 9 deletions

View File

@@ -422,8 +422,8 @@ InterferenceHelper::CalculatePayloadPer (Ptr<const Event> event, uint16_t channe
{
NS_LOG_FUNCTION (this << channelWidth << band.first << band.second << staId << window.first << window.second);
double psr = 1.0; /* Packet Success Rate */
auto niIt = nis->find (band)->second;
auto j = niIt.begin ();
const auto& niIt = nis->find (band)->second;
auto j = niIt.cbegin ();
Time previous = j->first;
WifiMode payloadMode = event->GetTxVector ().GetMode (staId);
Time phyPayloadStart = j->first;
@@ -435,7 +435,7 @@ InterferenceHelper::CalculatePayloadPer (Ptr<const Event> event, uint16_t channe
Time windowEnd = phyPayloadStart + window.second;
double noiseInterferenceW = m_firstPowerPerBand.find (band)->second;
double powerW = event->GetRxPowerW (band);
while (++j != niIt.end ())
while (++j != niIt.cend ())
{
Time current = j->first;
NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);

View File

@@ -163,15 +163,15 @@ TableBasedErrorRateModel::DoGetChunkSuccessRate (WifiMode mode, const WifiTxVect
}
auto errorTable = (ldpc ? AwgnErrorTableLdpc1458 : (size < m_threshold ? AwgnErrorTableBcc32 : AwgnErrorTableBcc1458));
auto itVector = errorTable[mcs];
auto itTable = std::find_if (itVector.begin(), itVector.end(),
const auto& itVector = errorTable[mcs];
auto itTable = std::find_if (itVector.cbegin (), itVector.cend (),
[&roundedSnr](const std::pair<double, double>& element) {
return element.first == roundedSnr;
});
double minSnr = itVector.begin ()->first;
double maxSnr = (--itVector.end ())->first;
double minSnr = itVector.cbegin ()->first;
double maxSnr = (--itVector.cend ())->first;
double per;
if (itTable == itVector.end ())
if (itTable == itVector.cend ())
{
if (roundedSnr < minSnr)
{
@@ -184,7 +184,7 @@ TableBasedErrorRateModel::DoGetChunkSuccessRate (WifiMode mode, const WifiTxVect
else
{
double a = 0.0, b = 0.0, previousSnr = 0.0, nextSnr = 0.0;
for (auto i = itVector.begin (); i != itVector.end (); ++i)
for (auto i = itVector.cbegin (); i != itVector.cend (); ++i)
{
if (i->first < roundedSnr)
{