fix: optimization: PVS-Studio warning V813

Passing large objects by const reference avoids unnecessary copying and enhances efficiency.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-02 05:35:55 +03:00
committed by Pugemon
parent 5b325ac2bc
commit 2c1103307f
42 changed files with 173 additions and 144 deletions
+7 -5
View File
@@ -59,8 +59,8 @@ void Batch2D::vertex(
buffer[index++] = a;
}
void Batch2D::vertex(
glm::vec2 point,
glm::vec2 uvpoint,
const glm::vec2& point,
const glm::vec2& uvpoint,
float r, float g, float b, float a
) {
buffer[index++] = point.x;
@@ -138,7 +138,7 @@ void Batch2D::rect(
UVRegion region,
bool flippedX,
bool flippedY,
glm::vec4 tint
const glm::vec4& tint
) {
if (index + 6*B2D_VERTEX_SIZE >= capacity) {
flush();
@@ -322,11 +322,13 @@ void Batch2D::rect(
vertex(v1, glm::vec2(0, 0), r2,g2,b2,1.0f);
}
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint){
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region,
const glm::vec4& tint){
rect(x, y, w, h, region.u1, region.v1, region.u2-region.u1, region.v2-region.v1, tint.r, tint.g, tint.b, tint.a);
}
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index, glm::vec4 tint){
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index,
const glm::vec4& tint){
float scale = 1.0f / (float)atlasRes;
float u = (index % atlasRes) * scale;
float v = 1.0f - ((index / atlasRes) * scale) - scale;