From b9bd9320772ce8af01adfd284be62f30290e831d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 15 Apr 2021 18:22:16 +0100 Subject: [PATCH] Micro optimize string concatenation in wxFileSystem::OpenFile() Concatenate the string only once instead of doing it several times. Compiler might be optimizing this anyhow in release builds, but it definitely helps in at least the debug ones and doesn't cost anything. --- src/common/filesys.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/filesys.cpp b/src/common/filesys.cpp index a81be7ba77..42b2a66717 100644 --- a/src/common/filesys.cpp +++ b/src/common/filesys.cpp @@ -480,14 +480,15 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location, int flags) // try relative paths first : if (meta != wxT(':') && !m_Path.empty()) { + const wxString fullloc = m_Path + loc; node = m_Handlers.GetFirst(); while (node) { wxFileSystemHandler *h = (wxFileSystemHandler*) node -> GetData(); - if (h->CanOpen(m_Path + loc)) + if (h->CanOpen(fullloc)) { - s = MakeLocal(h)->OpenFile(*this, m_Path + loc); - if (s) { m_LastName = m_Path + loc; break; } + s = MakeLocal(h)->OpenFile(*this, fullloc); + if (s) { m_LastName = fullloc; break; } } node = node->GetNext(); }