lte: fix redundant vector copy

This commit is contained in:
Tommaso Pecorella
2022-10-01 19:24:38 +02:00
committed by Tommaso Pecorella
parent fd5a6a44a3
commit 006690c628
2 changed files with 12 additions and 32 deletions

View File

@@ -1295,25 +1295,15 @@ void
LteSpectrumPhy::SetTxModeGain (uint8_t txMode, double gain)
{
NS_LOG_FUNCTION (this << " txmode " << (uint16_t)txMode << " gain " << gain);
// convert to linear
gain = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
if (txMode > 0)
{
m_txModeGain.resize (txMode);
}
std::vector <double> temp;
temp = m_txModeGain;
m_txModeGain.clear ();
for (uint8_t i = 0; i < temp.size (); i++)
{
if (i == txMode - 1)
// convert to linear
double gainLin = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
{
m_txModeGain.push_back (gain);
}
else
{
m_txModeGain.push_back (temp.at (i));
m_txModeGain.resize (txMode);
}
m_txModeGain.at (txMode - 1) = gainLin;
}
}

View File

@@ -1728,25 +1728,15 @@ void
LteUePhy::SetTxModeGain (uint8_t txMode, double gain)
{
NS_LOG_FUNCTION (this << gain);
// convert to linear
double gainLin = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
if (txMode > 0)
{
m_txModeGain.resize (txMode);
}
std::vector <double> temp;
temp = m_txModeGain;
m_txModeGain.clear ();
for (uint8_t i = 0; i < temp.size (); i++)
{
if (i == txMode - 1)
// convert to linear
double gainLin = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
{
m_txModeGain.push_back (gainLin);
}
else
{
m_txModeGain.push_back (temp.at (i));
m_txModeGain.resize (txMode);
}
m_txModeGain.at (txMode - 1) = gainLin;
}
// forward the info to DL LteSpectrumPhy
m_downlinkSpectrumPhy->SetTxModeGain (txMode, gain);