Make some arguments const/const references, where possible. NFC.
Found and suggested by clang-tidy.May help performance by reducing copies, depending on frequency of call, etc.pull/507/head
parent
65d0bdffdb
commit
e386d405d6
|
@ -1068,8 +1068,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static void ImportDwgDxf(const Platform::Path &filename,
|
||||
std::function<bool(const std::string &data, DRW_Interface *intf)> read) {
|
||||
static void
|
||||
ImportDwgDxf(const Platform::Path &filename,
|
||||
const std::function<bool(const std::string &data, DRW_Interface *intf)> &read) {
|
||||
std::string fileType = ToUpper(filename.Extension());
|
||||
|
||||
std::string data;
|
||||
|
|
|
@ -13,7 +13,7 @@ static System SYS;
|
|||
|
||||
static int IsInit = 0;
|
||||
|
||||
void SolveSpace::Platform::FatalError(std::string message) {
|
||||
void SolveSpace::Platform::FatalError(const std::string &message) {
|
||||
fprintf(stderr, "%s", message.c_str());
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ std::string AcceleratorDescription(const KeyboardEvent &accel);
|
|||
#if defined(__GNUC__)
|
||||
__attribute__((noreturn))
|
||||
#endif
|
||||
void FatalError(std::string message);
|
||||
void FatalError(const std::string &message);
|
||||
|
||||
// A native settings store.
|
||||
class Settings {
|
||||
|
|
|
@ -50,7 +50,7 @@ static std::string PrepareMnemonics(std::string label) {
|
|||
return label;
|
||||
}
|
||||
|
||||
static std::string PrepareTitle(std::string title) {
|
||||
static std::string PrepareTitle(const std::string &title) {
|
||||
return title + " — SolveSpace";
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static std::string PrepareTitle(std::string title) {
|
|||
// Fatal errors
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FatalError(std::string message) {
|
||||
void FatalError(const std::string &message) {
|
||||
fprintf(stderr, "%s", message.c_str());
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ crash_info_t crashAnnotation __attribute__((section("__DATA,__crash_info"))) = {
|
|||
CRASH_VERSION, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
void FatalError(std::string message) {
|
||||
void FatalError(const std::string &message) {
|
||||
crashAnnotation.message = message.c_str();
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Platform {
|
|||
// Fatal errors
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FatalError(std::string message) {
|
||||
void FatalError(const std::string &message) {
|
||||
fprintf(stderr, "%s", message.c_str());
|
||||
|
||||
#if !defined(LIBRARY) && defined(HAVE_BACKTRACE)
|
||||
|
|
|
@ -152,13 +152,12 @@ static int Clamp(int x, int a, int b) {
|
|||
|
||||
bool handlingFatalError = false;
|
||||
|
||||
void FatalError(std::string message) {
|
||||
void FatalError(const std::string &message) {
|
||||
// Indicate that we're handling a fatal error, to avoid re-entering application code
|
||||
// and potentially crashing even harder.
|
||||
handlingFatalError = true;
|
||||
|
||||
message += "\nGenerate debug report?";
|
||||
switch(MessageBoxW(NULL, Platform::Widen(message).c_str(),
|
||||
switch(MessageBoxW(NULL, Platform::Widen(message + "\nGenerate debug report?").c_str(),
|
||||
L"Fatal error — SolveSpace",
|
||||
MB_ICONERROR|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST|
|
||||
MB_OKCANCEL|MB_DEFBUTTON2)) {
|
||||
|
|
|
@ -403,11 +403,10 @@ public:
|
|||
|
||||
Vertex *AddVertex(const Vector &pos);
|
||||
Edge *AddEdge(const Vector &p0, const Vector &p1, uint32_t kind, uintptr_t data = 0);
|
||||
void Generate(
|
||||
std::function<void(Vertex *start, Vertex *next, Edge *edge)> startFunc,
|
||||
std::function<void(Vertex *next, Edge *edge)> nextFunc,
|
||||
std::function<void(Edge *)> aloneFunc,
|
||||
std::function<void()> endFunc = [](){});
|
||||
void Generate(std::function<void(Vertex *start, Vertex *next, Edge *edge)> const &startFunc,
|
||||
std::function<void(Vertex *next, Edge *edge)> const &nextFunc,
|
||||
std::function<void(Edge *)> const &aloneFunc,
|
||||
std::function<void()> const &endFunc = []() {});
|
||||
|
||||
void MakeFromEdges(const SEdgeList &sel);
|
||||
void MakeFromOutlines(const SOutlineList &sol);
|
||||
|
|
|
@ -141,10 +141,9 @@ PolylineBuilder::Edge *PolylineBuilder::AddEdge(const Vector &p0, const Vector &
|
|||
}
|
||||
|
||||
void PolylineBuilder::Generate(
|
||||
std::function<void(Vertex *start, Vertex *next, Edge *edge)> startFunc,
|
||||
std::function<void(Vertex *next, Edge *edge)> nextFunc,
|
||||
std::function<void(Edge *alone)> aloneFunc,
|
||||
std::function<void()> endFunc) {
|
||||
std::function<void(Vertex *start, Vertex *next, Edge *edge)> const &startFunc,
|
||||
std::function<void(Vertex *next, Edge *edge)> const &nextFunc,
|
||||
std::function<void(Edge *alone)> const &aloneFunc, std::function<void()> const &endFunc) {
|
||||
bool found;
|
||||
bool loop = false;
|
||||
do {
|
||||
|
|
|
@ -162,7 +162,7 @@ void Shader::Clear() {
|
|||
glDeleteProgram(program);
|
||||
}
|
||||
|
||||
void Shader::SetUniformMatrix(const char *name, double *md) {
|
||||
void Shader::SetUniformMatrix(const char *name, const double *md) {
|
||||
Enable();
|
||||
float mf[16];
|
||||
for(int i = 0; i < 16; i++) mf[i] = (float)md[i];
|
||||
|
@ -621,11 +621,11 @@ void EdgeRenderer::Draw(const SEdgeList &edges) {
|
|||
Remove(handle);
|
||||
}
|
||||
|
||||
void EdgeRenderer::SetModelview(double *matrix) {
|
||||
void EdgeRenderer::SetModelview(const double *matrix) {
|
||||
shader.SetUniformMatrix("modelview", matrix);
|
||||
}
|
||||
|
||||
void EdgeRenderer::SetProjection(double *matrix) {
|
||||
void EdgeRenderer::SetProjection(const double *matrix) {
|
||||
shader.SetUniformMatrix("projection", matrix);
|
||||
}
|
||||
|
||||
|
@ -833,11 +833,11 @@ void OutlineRenderer::Draw(const SOutlineList &outlines, Canvas::DrawOutlinesAs
|
|||
Remove(handle);
|
||||
}
|
||||
|
||||
void OutlineRenderer::SetModelview(double *matrix) {
|
||||
void OutlineRenderer::SetModelview(const double *matrix) {
|
||||
shader.SetUniformMatrix("modelview", matrix);
|
||||
}
|
||||
|
||||
void OutlineRenderer::SetProjection(double *matrix) {
|
||||
void OutlineRenderer::SetProjection(const double *matrix) {
|
||||
shader.SetUniformMatrix("projection", matrix);
|
||||
}
|
||||
|
||||
|
@ -1037,14 +1037,14 @@ bool IndexedMeshRenderer::NeedsTexture() const {
|
|||
selectedShader == &pointShader;
|
||||
}
|
||||
|
||||
void IndexedMeshRenderer::SetModelview(double *matrix) {
|
||||
void IndexedMeshRenderer::SetModelview(const double *matrix) {
|
||||
colShader.SetUniformMatrix("modelview", matrix);
|
||||
texShader.SetUniformMatrix("modelview", matrix);
|
||||
texaShader.SetUniformMatrix("modelview", matrix);
|
||||
pointShader.SetUniformMatrix("modelview", matrix);
|
||||
}
|
||||
|
||||
void IndexedMeshRenderer::SetProjection(double *matrix) {
|
||||
void IndexedMeshRenderer::SetProjection(const double *matrix) {
|
||||
colShader.SetUniformMatrix("projection", matrix);
|
||||
texShader.SetUniformMatrix("projection", matrix);
|
||||
texaShader.SetUniformMatrix("projection", matrix);
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
const std::vector<std::pair<GLuint, std::string>> &locations = {});
|
||||
void Clear();
|
||||
|
||||
void SetUniformMatrix(const char *name, double *md);
|
||||
void SetUniformMatrix(const char *name, const double *md);
|
||||
void SetUniformVector(const char *name, const Vector &v);
|
||||
void SetUniformVector(const char *name, const Vector4f &v);
|
||||
void SetUniformColor(const char *name, RgbaColor c);
|
||||
|
@ -163,8 +163,8 @@ public:
|
|||
void Draw(const Handle &handle);
|
||||
void Draw(const SEdgeList &edges);
|
||||
|
||||
void SetModelview(double *matrix);
|
||||
void SetProjection(double *matrix);
|
||||
void SetModelview(const double *matrix);
|
||||
void SetProjection(const double *matrix);
|
||||
void SetStroke(const Canvas::Stroke &stroke, double pixel);
|
||||
};
|
||||
|
||||
|
@ -203,8 +203,8 @@ public:
|
|||
void Draw(const Handle &handle, Canvas::DrawOutlinesAs mode);
|
||||
void Draw(const SOutlineList &outlines, Canvas::DrawOutlinesAs mode);
|
||||
|
||||
void SetModelview(double *matrix);
|
||||
void SetProjection(double *matrix);
|
||||
void SetModelview(const double *matrix);
|
||||
void SetProjection(const double *matrix);
|
||||
void SetStroke(const Canvas::Stroke &stroke, double pixel);
|
||||
};
|
||||
|
||||
|
@ -252,8 +252,8 @@ public:
|
|||
void Draw(const Handle &handle);
|
||||
void Draw(const SIndexedMesh &mesh);
|
||||
|
||||
void SetModelview(double *matrix);
|
||||
void SetProjection(double *matrix);
|
||||
void SetModelview(const double *matrix);
|
||||
void SetProjection(const double *matrix);
|
||||
|
||||
bool NeedsTexture() const;
|
||||
|
||||
|
|
|
@ -444,12 +444,11 @@ void ObjectPicker::DrawPixmap(std::shared_ptr<const Pixmap> pm,
|
|||
DrawQuad(o, o.Plus(u), o.Plus(u).Plus(v), o.Plus(v), hcf);
|
||||
}
|
||||
|
||||
bool ObjectPicker::Pick(std::function<void()> drawFn) {
|
||||
bool ObjectPicker::Pick(const std::function<void()> &drawFn) {
|
||||
minDistance = VERY_POSITIVE;
|
||||
maxZIndex = INT_MIN;
|
||||
|
||||
drawFn();
|
||||
return minDistance < selRadius;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
void DoQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d,
|
||||
int zIndex, int comparePosition = 0);
|
||||
|
||||
bool Pick(std::function<void()> drawFn);
|
||||
bool Pick(const std::function<void()> &drawFn);
|
||||
};
|
||||
|
||||
// A canvas that renders onto a 2d surface, performing z-index sorting, occlusion testing, etc,
|
||||
|
|
|
@ -918,7 +918,7 @@ Vector VectorFont::GetExtents(double forCapHeight, const std::string &str) {
|
|||
}
|
||||
|
||||
void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str,
|
||||
std::function<void(Vector, Vector)> traceEdge) {
|
||||
const std::function<void(Vector, Vector)> &traceEdge) {
|
||||
ssassert(!IsEmpty(), "Expected a loaded font");
|
||||
|
||||
double scale = (forCapHeight / capHeight);
|
||||
|
@ -945,7 +945,7 @@ void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const
|
|||
}
|
||||
|
||||
void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str,
|
||||
std::function<void(Vector, Vector)> traceEdge, const Camera &camera) {
|
||||
const std::function<void(Vector, Vector)> &traceEdge, const Camera &camera) {
|
||||
ssassert(!IsEmpty(), "Expected a loaded font");
|
||||
|
||||
// Perform grid-fitting only when the text is parallel to the view plane.
|
||||
|
|
|
@ -103,9 +103,9 @@ public:
|
|||
Vector GetExtents(double forCapHeight, const std::string &str);
|
||||
|
||||
void Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str,
|
||||
std::function<void(Vector, Vector)> traceEdge);
|
||||
const std::function<void(Vector, Vector)> &traceEdge);
|
||||
void Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str,
|
||||
std::function<void(Vector, Vector)> traceEdge, const Camera &camera);
|
||||
const std::function<void(Vector, Vector)> &traceEdge, const Camera &camera);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue