Skip to content

Commit 0deee30

Browse files
committed
Improve const correctness
1 parent 34a4788 commit 0deee30

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

imgui-SFML.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void setClipboardText(void* /*userData*/, const char* text)
209209
{
210210
static std::string s_clipboardText;
211211

212-
auto tmp = sf::Clipboard::getString().toUtf8();
212+
const auto tmp = sf::Clipboard::getString().toUtf8();
213213
s_clipboardText.assign(tmp.begin(), tmp.end());
214214
return s_clipboardText.c_str();
215215
}
@@ -349,10 +349,10 @@ bool Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF
349349

350350
void SetCurrentWindow(const sf::Window& window)
351351
{
352-
auto found = std::find_if(s_windowContexts.begin(),
353-
s_windowContexts.end(),
354-
[&](std::unique_ptr<WindowContext>& ctx)
355-
{ return ctx->window->getNativeHandle() == window.getNativeHandle(); });
352+
const auto found = std::find_if(s_windowContexts.begin(),
353+
s_windowContexts.end(),
354+
[&](std::unique_ptr<WindowContext>& ctx)
355+
{ return ctx->window->getNativeHandle() == window.getNativeHandle(); });
356356
assert(found != s_windowContexts.end() &&
357357
"Failed to find the window. Forgot to call ImGui::SFML::Init for the window?");
358358
s_currWindowCtx = found->get();
@@ -589,18 +589,18 @@ void Shutdown(const sf::Window& window)
589589
const bool needReplacement = (s_currWindowCtx->window->getNativeHandle() == window.getNativeHandle());
590590

591591
// remove window's context
592-
auto found = std::find_if(s_windowContexts.begin(),
593-
s_windowContexts.end(),
594-
[&](std::unique_ptr<WindowContext>& ctx)
595-
{ return ctx->window->getNativeHandle() == window.getNativeHandle(); });
592+
const auto found = std::find_if(s_windowContexts.begin(),
593+
s_windowContexts.end(),
594+
[&](std::unique_ptr<WindowContext>& ctx)
595+
{ return ctx->window->getNativeHandle() == window.getNativeHandle(); });
596596
assert(found != s_windowContexts.end() &&
597597
"Window wasn't inited properly: forgot to call ImGui::SFML::Init(window)?");
598598
s_windowContexts.erase(found); // s_currWindowCtx can become invalid here!
599599

600600
// set current context to some window for convenience if needed
601601
if (needReplacement)
602602
{
603-
auto it = s_windowContexts.begin();
603+
const auto it = s_windowContexts.begin();
604604
if (it != s_windowContexts.end())
605605
{
606606
// set to some other window
@@ -835,7 +835,7 @@ void Image(const sf::Sprite& sprite, const sf::Color& tintColor, const sf::Color
835835

836836
void Image(const sf::Sprite& sprite, const sf::Vector2f& size, const sf::Color& tintColor, const sf::Color& borderColor)
837837
{
838-
auto [uv0, uv1, textureID] = getSpriteTextureData(sprite);
838+
const auto [uv0, uv1, textureID] = getSpriteTextureData(sprite);
839839
ImGui::Image(textureID, toImVec2(size), uv0, uv1, toImColor(tintColor), toImColor(borderColor));
840840
}
841841

@@ -876,7 +876,7 @@ bool ImageButton(const char* id,
876876

877877
bool ImageButton(const char* id, const sf::Sprite& sprite, const sf::Vector2f& size, const sf::Color& bgColor, const sf::Color& tintColor)
878878
{
879-
auto [uv0, uv1, textureID] = getSpriteTextureData(sprite);
879+
const auto [uv0, uv1, textureID] = getSpriteTextureData(sprite);
880880
return ImGui::ImageButton(id, textureID, toImVec2(size), uv0, uv1, toImColor(bgColor), toImColor(tintColor));
881881
}
882882

0 commit comments

Comments
 (0)