Fix clang-tidy performance-unnecessary-copy-initialization warnings
Detected by clang-tidy-19
This commit is contained in:
@@ -41,7 +41,7 @@ DesMetrics::Initialize(std::vector<std::string> args, std::string outDir /* = ""
|
||||
std::string model_name("desTraceFile");
|
||||
if (!args.empty())
|
||||
{
|
||||
std::string arg0 = args[0];
|
||||
const std::string& arg0 = args[0];
|
||||
model_name = SystemPath::Split(arg0).back();
|
||||
}
|
||||
std::string jsonFile = model_name + ".json";
|
||||
|
||||
@@ -351,7 +351,7 @@ Exists(const std::string path)
|
||||
|
||||
// Check if the file itself exists
|
||||
auto tokens = Split(path);
|
||||
std::string file = tokens.back();
|
||||
const std::string& file = tokens.back();
|
||||
|
||||
if (file.empty())
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ Ipv4Interface::RemoveAddress(uint32_t index)
|
||||
{
|
||||
if (tmp == index)
|
||||
{
|
||||
Ipv4InterfaceAddress addr = *i;
|
||||
const Ipv4InterfaceAddress& addr = *i;
|
||||
m_ifaddrs.erase(i);
|
||||
if (!m_removeAddressCallback.IsNull())
|
||||
{
|
||||
@@ -388,7 +388,7 @@ Ipv4Interface::RemoveAddress(Ipv4Address address)
|
||||
{
|
||||
if ((*it).GetLocal() == address)
|
||||
{
|
||||
Ipv4InterfaceAddress ifAddr = *it;
|
||||
const Ipv4InterfaceAddress& ifAddr = *it;
|
||||
m_ifaddrs.erase(it);
|
||||
if (!m_removeAddressCallback.IsNull())
|
||||
{
|
||||
|
||||
@@ -2520,7 +2520,7 @@ AnimationInterface::WriteXmlRp(uint32_t nodeId,
|
||||
element.AddAttribute("c", rpElements.size());
|
||||
for (auto i = rpElements.begin(); i != rpElements.end(); ++i)
|
||||
{
|
||||
Ipv4RoutePathElement rpElement = *i;
|
||||
const Ipv4RoutePathElement& rpElement = *i;
|
||||
AnimXmlElement rpeElement("rpe");
|
||||
rpeElement.AddAttribute("n", rpElement.nodeId);
|
||||
rpeElement.AddAttribute("nH", rpElement.nextHop.c_str());
|
||||
|
||||
@@ -642,7 +642,7 @@ PacketTest::DoRun()
|
||||
|
||||
{
|
||||
Packet c0 = *copy;
|
||||
Packet c1 = *copy;
|
||||
Packet c1 = *copy; // NOLINT(performance-unnecessary-copy-initialization)
|
||||
c0 = c1;
|
||||
CHECK(&c0, 1, E(1, 0, 1000));
|
||||
CHECK(&c1, 1, E(1, 0, 1000));
|
||||
|
||||
@@ -104,7 +104,7 @@ OmnetDataOutput::Output(DataCollector& dc)
|
||||
|
||||
for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++)
|
||||
{
|
||||
std::pair<std::string, std::string> blob = (*i);
|
||||
const auto& blob = (*i);
|
||||
scalarFile << "attr \"" << blob.first << "\" \"" << blob.second << "\"" << std::endl;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ OmnetDataOutput::Output(DataCollector& dc)
|
||||
}
|
||||
for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++)
|
||||
{
|
||||
std::pair<std::string, std::string> blob = (*i);
|
||||
const auto& blob = (*i);
|
||||
if (isNumeric(blob.second))
|
||||
{
|
||||
scalarFile << "scalar . \"" << blob.first << "\" \"" << blob.second << "\""
|
||||
|
||||
@@ -107,7 +107,7 @@ SqliteDataOutput::Output(DataCollector& dc)
|
||||
|
||||
for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++)
|
||||
{
|
||||
std::pair<std::string, std::string> blob = (*i);
|
||||
const auto& blob = (*i);
|
||||
SQLiteOutput::SpinReset(stmt);
|
||||
m_sqliteOut->Bind(stmt, 1, run);
|
||||
m_sqliteOut->Bind(stmt, 2, blob.first);
|
||||
|
||||
@@ -957,7 +957,7 @@ WifiPhyRxTraceSink::CountStatistics(uint32_t nodeId, uint32_t deviceId, uint8_t
|
||||
auto mapOfDevices = m_completedRecords.at(nodeId);
|
||||
if (mapOfDevices.contains(deviceId))
|
||||
{
|
||||
auto mapOfLinks = mapOfDevices.at(deviceId);
|
||||
const auto& mapOfLinks = mapOfDevices.at(deviceId);
|
||||
if (mapOfLinks.contains(linkId))
|
||||
{
|
||||
auto vectorOfRecords = mapOfLinks.at(linkId);
|
||||
|
||||
@@ -1180,7 +1180,7 @@ BaseStationNetDevice::MarkUplinkAllocations()
|
||||
std::list<OfdmUlMapIe> uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations();
|
||||
for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter)
|
||||
{
|
||||
OfdmUlMapIe uplinkAllocation = *iter;
|
||||
const OfdmUlMapIe& uplinkAllocation = *iter;
|
||||
|
||||
if (uplinkAllocation.GetUiuc() == OfdmUlBurstProfile::UIUC_END_OF_MAP)
|
||||
{
|
||||
|
||||
@@ -1166,7 +1166,7 @@ SubscriberStationNetDevice::ProcessUlMap(const UlMap& ulmap)
|
||||
|
||||
for (auto iter = ulMapElements.begin(); iter != ulMapElements.end(); ++iter)
|
||||
{
|
||||
OfdmUlMapIe ulMapIe = *iter;
|
||||
const OfdmUlMapIe& ulMapIe = *iter;
|
||||
|
||||
if (ulMapIe.GetUiuc() == OfdmUlBurstProfile::UIUC_END_OF_MAP)
|
||||
{
|
||||
@@ -1267,7 +1267,7 @@ SubscriberStationNetDevice::ProcessDcd(const Dcd& dcd)
|
||||
|
||||
for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter)
|
||||
{
|
||||
OfdmDlBurstProfile brstProfile = *iter;
|
||||
const OfdmDlBurstProfile& brstProfile = *iter;
|
||||
|
||||
/*NS-2 does this, may be not correct, assumes DIUC/UIUC to
|
||||
modulation type mapping in DCD/UCD may change over time*/
|
||||
@@ -1302,7 +1302,7 @@ SubscriberStationNetDevice::ProcessUcd(const Ucd& ucd)
|
||||
|
||||
for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter)
|
||||
{
|
||||
OfdmUlBurstProfile brstProfile = *iter;
|
||||
const OfdmUlBurstProfile& brstProfile = *iter;
|
||||
|
||||
/*NS-2 does this, may be not correct, assumes DIUC/UIUC to
|
||||
modulation type mapping in DCD/UCD may change over time*/
|
||||
|
||||
Reference in New Issue
Block a user