Skip to content

Commit

Permalink
Cleanup of pessimizing-move and reorder warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Aug 29, 2023
1 parent 2f021e4 commit 79e2d55
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 46 deletions.
2 changes: 1 addition & 1 deletion rts/Game/UI/GuiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3680,7 +3680,7 @@ void CGuiHandler::DrawMapStuff(bool onMiniMap)
if ((size_t(inCommand) < commands.size()) && (commands[inCommand].type == CMDTYPE_ICON_BUILDING)) {
{
// draw build distance for all immobile builders during build commands
for (const auto bi: unitHandler.GetBuilderCAIs()) {
for (const auto& bi: unitHandler.GetBuilderCAIs()) {
const CBuilderCAI* builderCAI = bi.second;
const CUnit* builder = builderCAI->owner;
const UnitDef* builderDef = builder->unitDef;
Expand Down
2 changes: 1 addition & 1 deletion rts/Game/UI/QuitBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void CQuitBox::MouseRelease(int x, int y, int button)

// save current game state
if (save) {
const std::string currTimeStr = std::move(CTimeUtil::GetCurrentTimeStr());
const std::string currTimeStr = CTimeUtil::GetCurrentTimeStr();
const std::string saveFileName = currTimeStr + "_" + modInfo.filename + "_" + gameSetup->mapName;

game->Save("Saves/" + saveFileName + ".ssf", "");
Expand Down
3 changes: 2 additions & 1 deletion rts/Rendering/GlobalRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ CGlobalRendering::CGlobalRendering()
, viewWindowOffsetY(0)

// dual viewport geometry (DualScreenMode = 1)
, dualWindowOffsetY(0)
, dualViewPosX(0)
, dualViewPosY(0)
, dualViewSizeX(0)
, dualViewSizeY(0)
, dualWindowOffsetY(0)


, winBorder{ 0 }

Expand Down
19 changes: 6 additions & 13 deletions rts/Rendering/GroundFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,13 @@ bool CStandardGroundFlash::GetMemberInfo(SExpGenSpawnableMemberInfo& memberInfo)


CSimpleGroundFlash::CSimpleGroundFlash()
: texture(nullptr)
, colorMap(nullptr)
, agerate(0.0f)
, age(0.0f)
: sizeGrowth(0.0f)
, ttl(0)
, sizeGrowth(0.0f)
{

}
, age(0.0f)
, agerate(0.0f)
, colorMap(nullptr)
, texture(nullptr)
{}

void CSimpleGroundFlash::Serialize(creg::ISerializer* s)
{
Expand Down Expand Up @@ -320,11 +318,6 @@ void CSimpleGroundFlash::Draw()
unsigned char color[4] = {0, 0, 0, 0};
colorMap->GetColor(color, age);

const float3 p1 = pos + (-side1 - side2) * size;
const float3 p2 = pos + ( side1 - side2) * size;
const float3 p3 = pos + ( side1 + side2) * size;
const float3 p4 = pos + (-side1 + side2) * size;

std::array<float3, 4> bounds = {
(-side1 - side2) * size,
( side1 - side2) * size,
Expand Down
5 changes: 2 additions & 3 deletions rts/Rendering/Models/3DModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,10 @@ void LocalModel::UpdateBoundingVolume()
*/

LocalModelPiece::LocalModelPiece(const S3DModelPiece* piece)
: dirty(true)
: colvol(piece->GetCollisionVolume())
, dirty(true)
, customDirty(true)

, colvol(piece->GetCollisionVolume())

, scriptSetVisible(true)
, blockScriptAnims(false)

Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Models/AssParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ void CAssParser::BuildPieceHierarchy(S3DModel* model, ModelPieceMap& pieceMap, c
// Iterate over the model and calculate its overall dimensions
void CAssParser::CalculateModelDimensions(S3DModel* model, S3DModelPiece* piece)
{
const CMatrix44f scaleRotMat = std::move(piece->ComposeTransform(ZeroVector, ZeroVector, piece->scales));
const CMatrix44f scaleRotMat = piece->ComposeTransform(ZeroVector, ZeroVector, piece->scales);

// cannot set this until parent relations are known, so either here or in BuildPieceHierarchy()
piece->goffset = scaleRotMat.Mul(piece->offset) + ((piece->parent != nullptr)? piece->parent->goffset: ZeroVector);
Expand Down
4 changes: 2 additions & 2 deletions rts/Rendering/Models/ModelRenderContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class ModelRenderContainer {
typedef typename decltype(bins)::value_type ObjectBin;
public:
ModelRenderContainer(TObjectSelector objectSelector_)
: objectSelector{std::move(objectSelector_)}
, numObjs{ 0 }
: numObjs{ 0 }
, numBins{ 0 }
, objectSelector{std::move(objectSelector_)}
{
bins.reserve(32);
Clear();
Expand Down
5 changes: 3 additions & 2 deletions rts/Rendering/OGLDBInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ namespace {
}

OGLDBInfo::OGLDBInfo(const std::string& glRenderer_, const std::string& myOS_)
: myOS{ StringToLower(myOS_) }
, glRenderer{ StringToLower(glRenderer_) }
: glRenderer{ StringToLower(glRenderer_) }
, myOS{ StringToLower(myOS_) }
, maxVer{0, 0}
, id{""}
, drv{""}
{
fut = std::async(std::launch::async, [this]() -> bool {
try {
Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Textures/3DOTextureHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct TexFile {

void C3DOTextureHandler::Init()
{
std::vector<TexFile> texFiles = std::move(LoadTexFiles());
std::vector<TexFile> texFiles = LoadTexFiles();

// TODO: make this use TextureAtlas directly
CTextureAtlas atlas;
Expand Down
5 changes: 2 additions & 3 deletions rts/Rendering/Textures/TextureAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ CR_REG_METADATA(AtlasedTexture, (CR_IGNORED(x), CR_IGNORED(y), CR_IGNORED(z), CR

const AtlasedTexture AtlasedTexture::DefaultAtlasTexture = AtlasedTexture{};
CTextureAtlas::CTextureAtlas(uint32_t allocType_, int32_t atlasSizeX_, int32_t atlasSizeY_, const std::string& name_, bool reloadable_)
: name{ name_ }
, allocType{ allocType_ }
: allocType{ allocType_ }
, atlasSizeX{ atlasSizeX_ }
, atlasSizeY{ atlasSizeY_ }
, reloadable{ reloadable_ }
, name{ name_ }
{

textures.reserve(256);
Expand Down Expand Up @@ -167,7 +167,6 @@ bool CTextureAtlas::CreateTexture()
// make spacing between textures black transparent to avoid ugly lines with linear filtering
std::memset(data, 0, atlasSize.x * atlasSize.y * 4);

int iter = 0;
for (const MemTex& memTex: memTextures) {
const float4 texCoords = atlasAllocator->GetTexCoords(memTex.names[0]);
const float4 absCoords = atlasAllocator->GetEntry(memTex.names[0]);
Expand Down
15 changes: 8 additions & 7 deletions rts/Sim/Path/QTPFS/PathSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ namespace QTPFS {

public:
PathSearch()
: nodeLayer(NULL)
, searchExec(NULL)
, hCostMult(0.0f)
, haveFullPath(false)
, havePartPath(false)
, openNodes(nullptr)
, searchID(0)
: searchID(0)
, searchTeam(0)
, searchType(0)
, searchState(0)
, openNodes(nullptr)
, nodeLayer(nullptr)
, searchExec(nullptr)
, hCostMult(0.0f)
, haveFullPath(false)
, havePartPath(false)

{}
PathSearch(unsigned int pathSearchType)
: PathSearch()
Expand Down
8 changes: 4 additions & 4 deletions rts/Sim/Projectiles/ExpGenSpawnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ std::array<CExpGenSpawnable::SpawnableTuple, 14> CExpGenSpawnable::spawnables =

CExpGenSpawnable::CExpGenSpawnable(const float3& pos, const float3& spd)
: CWorldObject(pos, spd)
, createFrame{0}
, rotVal{0}
, rotVel{0}
, rotVal{ 0 }
, rotVel{ 0 }
, createFrame{ 0 }
{
assert(projMemPool.alloced(this));
}

CExpGenSpawnable::CExpGenSpawnable()
: CWorldObject()
, createFrame{ 0 }
, rotVal{ 0 }
, rotVel{ 0 }
, createFrame{ 0 }
{
assert(projMemPool.alloced(this));
}
Expand Down
2 changes: 0 additions & 2 deletions rts/Sim/Projectiles/FireProjectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ void CFireProjectile::Draw()
uint8_t col[4];
col[3] = 1;
uint8_t col2[4];
size_t sz2 = subParticles2.size();
size_t sz = subParticles.size();

for (const SubParticle& pi: subParticles2) {
const float age = pi.age + ageSpeed * globalRendering->timeOffset;
Expand Down
2 changes: 1 addition & 1 deletion rts/System/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ template<typename T, typename F, typename... A> std::string ControlReverseIterat
for (size_t i = 0; i < list.size(); i++) {
CEventClient* ec = list[list.size() - 1 - i];

std::string str = std::move((ec->*func)(std::forward<A>(args)...));
std::string str = (ec->*func)(std::forward<A>(args)...);

if (str.empty())
continue;
Expand Down
2 changes: 1 addition & 1 deletion rts/System/LoadSave/CregLoadSaveHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void CCregLoadSaveHandler::SaveGame(const std::string& path)
return;
}

std::string data = std::move(oss.str());
std::string data = oss.str();
std::function<void(gzFile, std::string&&)> func = [](gzFile file, std::string&& data) {
gzwrite(file, data.c_str(), data.size());
gzflush(file, Z_FINISH);
Expand Down
2 changes: 1 addition & 1 deletion rts/System/QueueToMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace spring {
std::apply(storedFunc, storedArgs);
}
private:
std::tuple<std::decay_t<Args>...> storedArgs;
FunctionType storedFunc;
std::tuple<std::decay_t<Args>...> storedArgs;
};
}
4 changes: 2 additions & 2 deletions rts/lib/lru/LruClockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ namespace spring {
// takes a LruKey as key and LruValue as value

LRUClockCache(CHInt numElements, const decltype(loadData)& readMiss, const decltype(saveData)& writeMiss)
: size{ numElements }
, loadData{ readMiss }
: loadData{ readMiss }
, saveData{ writeMiss }
, size{ numElements }
, ctr{ 0 }
, ctrEvict{ numElements >> 1 } // 50% phase difference between eviction and second-chance hands of the "second-chance" CLOCK algorithm
{
Expand Down

0 comments on commit 79e2d55

Please sign in to comment.