Remove ignore_result

`std::ignore` serves the same purpose and is C++ standard.
This commit is contained in:
phosit
2025-05-21 13:49:23 +02:00
committed by phosit
parent 5b8cb7f34b
commit 93666d8628
10 changed files with 30 additions and 27 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -27,6 +27,7 @@
#include "ps/Filesystem.h"
#include <cmath>
#include <utility>
CHeightMipmap::CHeightMipmap()
{
@@ -255,5 +256,5 @@ void CHeightMipmap::DumpToDisk(const VfsPath& filename) const
DynArray da;
WARN_IF_ERR(t.encode(filename.Extension(), &da));
g_VFS->CreateFile(filename, DummySharedPtr(da.base), da.pos);
ignore_result(da_free(&da));
std::ignore = da_free(&da);
}
+4 -2
View File
@@ -37,6 +37,8 @@
#include "js/Equality.h"
#include <utility>
namespace
{
@@ -468,11 +470,11 @@ void CGUIManager::DisplayLoadProgress(int percent, const wchar_t* pending_task)
JS::RootedValueVector paramData(rq.cx);
ignore_result(paramData.append(JS::NumberValue(percent)));
std::ignore = paramData.append(JS::NumberValue(percent));
JS::RootedValue valPendingTask(rq.cx);
Script::ToJSVal(rq, &valPendingTask, pending_task);
ignore_result(paramData.append(valPendingTask));
std::ignore = paramData.append(valPendingTask);
SendEventToAll(EVENT_NAME_GAME_LOAD_PROGRESS, paramData);
}
+2 -2
View File
@@ -35,7 +35,7 @@
#include <algorithm>
#include <string_view>
#include <unordered_map>
#include <utility>
const CStr IGUIObject::EventNameMouseEnter = "MouseEnter";
const CStr IGUIObject::EventNameMouseMove = "MouseMove";
@@ -409,7 +409,7 @@ InReaction IGUIObject::SendMouseEvent(EGUIMessageType type, const CStr& eventNam
"y", mousePos.Y,
"buttons", m_pGUI.GetMouseButtons());
JS::RootedValueVector paramData(rq.cx);
ignore_result(paramData.append(mouse));
std::ignore = paramData.append(mouse);
ScriptEvent(eventName, paramData);
if (type == GUIM_MOUSE_WHEEL_UP || type == GUIM_MOUSE_WHEEL_DOWN || type == GUIM_MOUSE_WHEEL_LEFT || type == GUIM_MOUSE_WHEEL_RIGHT)
+4 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2023 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -52,6 +52,7 @@
#include <array>
#include <cmath>
#include <utility>
#include <vector>
namespace
@@ -257,8 +258,8 @@ bool CMiniMap::FireWorldClickEvent(int button, int UNUSED(clicks))
Script::ToJSVal(rq, &buttonJs, button);
JS::RootedValueVector paramData(rq.cx);
ignore_result(paramData.append(coords));
ignore_result(paramData.append(buttonJs));
std::ignore = paramData.append(coords);
std::ignore = paramData.append(buttonJs);
return ScriptEventWithReturn(EventNameWorldClick, paramData);
}
-8
View File
@@ -54,14 +54,6 @@
# define UNUSED2(param) ((void)(param))
#endif
/**
* Silence the 'unused result' warning.
* (void) would be sufficient but Spidermonkey still uses warn_unused_result,
* and GCC is stricter about that. See https://bugzilla.mozilla.org/show_bug.cgi?id=1571631.
**/
template<typename T>
inline void ignore_result(const T&) {}
/**
* indicate a function will not throw any synchronous exceptions,
* thus hopefully generating smaller and more efficient code.
@@ -26,6 +26,8 @@
#include "lib/file/vfs/vfs_populate.h"
#include "lib/os_path.h"
#include <utility>
static OsPath TEST_FOLDER(DataDir()/"_test.temp");
extern PIVFS g_VFS;
@@ -107,7 +109,7 @@ public:
g_VFS->Mount(L"mod", TEST_FOLDER / "mod_b" / "", 0, 0);
// For consistency, populate everything.
ignore_result(g_VFS->TextRepresentation().c_str());
std::ignore = g_VFS->TextRepresentation().c_str();
OsPath realPath;
g_VFS->GetDirectoryRealPath(L"mod", realPath);
+3 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -26,6 +26,7 @@
#include "ps/Pyrogenesis.h"
#include <iomanip>
#include <utility>
// not thread-safe!
static const wchar_t* HardcodedErrorString(int err)
@@ -68,7 +69,7 @@ Status tex_write(Tex* t, const VfsPath& filename)
ret = (Status)bytes_written;
}
ignore_result(da_free(&da));
std::ignore = da_free(&da);
return ret;
}
+1 -1
View File
@@ -237,7 +237,7 @@ private:
return false;
JS::RootedValueVector argv(rq.cx);
ignore_result(argv.resize(sizeof...(Args)));
std::ignore = argv.resize(sizeof...(Args));
ToJSValVector(std::index_sequence_for<Args...>{}, rq, &argv, args...);
bool success;
@@ -50,6 +50,8 @@
#include "simulation2/serialization/StdDeserializer.h"
#include "simulation2/serialization/StdSerializer.h"
#include <utility>
extern void QuitEngine();
/**
@@ -160,7 +162,7 @@ private:
}
JS::RootedValueVector argv(rq.cx);
ignore_result(argv.append(settings.get()));
std::ignore = argv.append(settings.get());
m_ScriptInterface->CallConstructor(ctor, argv, &m_Obj);
if (m_Obj.get().isNull())
@@ -459,7 +461,7 @@ public:
"templates", m_EntityTemplates);
JS::RootedValueVector argv(rq.cx);
ignore_result(argv.append(settings));
std::ignore = argv.append(settings);
m_ScriptInterface->CallConstructor(ctor, argv, &m_SharedAIObj);
if (m_SharedAIObj.get().isNull())
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -27,6 +27,8 @@
#include "scriptinterface/JSON.h"
#include "simulation2/Simulation2.h"
#include <utility>
const CStr CReplayTurnManager::EventNameReplayFinished = "ReplayFinished";
const CStr CReplayTurnManager::EventNameReplayOutOfSync = "ReplayOutOfSync";
@@ -94,15 +96,15 @@ void CReplayTurnManager::NotifyFinishedUpdate(u32 turn)
JS::RootedValueVector paramData(rq.cx);
ignore_result(paramData.append(JS::NumberValue(turn)));
std::ignore = paramData.append(JS::NumberValue(turn));
JS::RootedValue hashVal(rq.cx);
Script::ToJSVal(rq, &hashVal, hash);
ignore_result(paramData.append(hashVal));
std::ignore = paramData.append(hashVal);
JS::RootedValue expectedHashVal(rq.cx);
Script::ToJSVal(rq, &expectedHashVal, expectedHash);
ignore_result(paramData.append(expectedHashVal));
std::ignore = paramData.append(expectedHashVal);
g_GUI->SendEventToAll(EventNameReplayOutOfSync, paramData);
}