Skip to content
This repository
Browse code

Don't create std::string on glCheckError unless necessary.

  • Loading branch information...
commit f9b3e513d2cb70831552e0e081514010c9a0356a 1 parent 044eb85
Christian Forfang cforfang authored
5 src/SFML/Graphics/GLCheck.cpp
@@ -34,13 +34,14 @@ namespace sf
34 34 namespace priv
35 35 {
36 36 ////////////////////////////////////////////////////////////
37   -void glCheckError(const std::string& file, unsigned int line)
  37 +void glCheckError(const char* file, unsigned int line)
38 38 {
39 39 // Get the last error
40 40 GLenum errorCode = glGetError();
41 41
42 42 if (errorCode != GL_NO_ERROR)
43 43 {
  44 + std::string fileString(file);
44 45 std::string error = "unknown error";
45 46 std::string description = "no description";
46 47
@@ -99,7 +100,7 @@ void glCheckError(const std::string& file, unsigned int line)
99 100
100 101 // Log the error
101 102 err() << "An internal OpenGL call failed in "
102   - << file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : "
  103 + << fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : "
103 104 << error << ", " << description
104 105 << std::endl;
105 106 }
2  src/SFML/Graphics/GLCheck.hpp
@@ -59,7 +59,7 @@ namespace priv
59 59 /// \param line Line number of the source file where the call is located
60 60 ///
61 61 ////////////////////////////////////////////////////////////
62   -void glCheckError(const std::string& file, unsigned int line);
  62 +void glCheckError(const char* file, unsigned int line);
63 63
64 64 ////////////////////////////////////////////////////////////
65 65 /// \brief Make sure that GLEW is initialized

2 comments on commit f9b3e51

R3dev

And how would you justify that?

Christian Forfang

Did you see the pull-request?

Please sign in to comment.
Something went wrong with that request. Please try again.