From 80464d0bc1214fae94189741c61f00b96c81cbd4 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 10 Oct 2026 15:06:57 +0200 Subject: [PATCH] refactor(sonar): construct elements in place with emplace_back (cpp:S6003) Co-Authored-By: Claude Opus 5.5 --- gl/vao.cpp | 2 +- scripting/PyInt.cpp | 2 +- utilities/Logs.cpp | 2 +- world/Segment.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gl/vao.cpp b/gl/vao.cpp index 6d1e055d..6c36a1ef 100644 --- a/gl/vao.cpp +++ b/gl/vao.cpp @@ -31,7 +31,7 @@ void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, i else { if (attrib == 0) params.clear(); - params.push_back({buffer, attrib, size, type, stride, offset}); + params.emplace_back(buffer, attrib, size, type, stride, offset); active = nullptr; } } diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp index 6cc6c902..6ebfe639 100644 --- a/scripting/PyInt.cpp +++ b/scripting/PyInt.cpp @@ -712,7 +712,7 @@ std::vector python_external_utils::PyObjectToStringArray(PyObject * return emptyIfError; } - result.push_back(std::string(str)); + result.emplace_back(str); Py_DECREF(item); // Decrease reference count for the item } diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp index 28345b30..c26896e9 100644 --- a/utilities/Logs.cpp +++ b/utilities/Logs.cpp @@ -175,7 +175,7 @@ void WriteLog(std::string_view str, logtype type, bool isError) const auto message = FormatLogMessage(str); std::scoped_lock lock(logMutex); - InfoStack.push_back({message, isError}); + InfoStack.emplace_back(message, isError); } void ErrorLog(std::string_view str, logtype type) diff --git a/world/Segment.cpp b/world/Segment.cpp index ed63eef1..a53f3fbe 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -572,16 +572,16 @@ void TSegment::render_lines(std::vector &out, float quality) glm::vec3 previous = FastGetPoint(0.0); for (x = step; x <= 1.0f; x += step) { - out.push_back(gfx::basic_vertex(previous, glm::vec3(0.0f), glm::vec2(0.0f))); + out.emplace_back(previous, glm::vec3(0.0f), glm::vec2(0.0f)); previous = glm::vec3(FastGetPoint(x)); - out.push_back(gfx::basic_vertex(previous, glm::vec3(0.0f), glm::vec2(0.0f))); + out.emplace_back(previous, glm::vec3(0.0f), glm::vec2(0.0f)); } - out.push_back(gfx::basic_vertex(previous, glm::vec3(0.0f), glm::vec2(0.0f))); + out.emplace_back(previous, glm::vec3(0.0f), glm::vec2(0.0f)); previous = glm::vec3(FastGetPoint(1.0)); - out.push_back(gfx::basic_vertex(previous, glm::vec3(0.0f), glm::vec2(0.0f))); + out.emplace_back(previous, glm::vec3(0.0f), glm::vec2(0.0f)); } glm::vec3 TSegment::get_nearest_point(const glm::dvec3 &point, float quality) const