From 78696bdaee535bbd1a1faad6981c8e53873bc566 Mon Sep 17 00:00:00 2001 From: bofdahof <172177156+bofdahof@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:42:29 +1000 Subject: [PATCH] Join declaration and assignment --- src/App/Application.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index de2094f275..40bec112e5 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -554,9 +554,8 @@ void Application::closeAllDocuments() App::Document* Application::getDocument(const char *Name) const { - std::map::const_iterator pos; - pos = DocMap.find(Name); + const auto pos = DocMap.find(Name); if (pos == DocMap.end()) return nullptr; @@ -1056,10 +1055,7 @@ void Application::setActiveDocument(const char* Name) return; } - std::map::iterator pos; - pos = DocMap.find(Name); - - if (pos != DocMap.end()) { + if (const auto pos = DocMap.find(Name); pos != DocMap.end()) { setActiveDocument(pos->second); } else { @@ -3484,12 +3480,11 @@ std::string Application::FindHomePath(const char* call) // FreeCAD shared library. if (!Py_IsInitialized()) { uint32_t sz = 0; - char *buf; - _NSGetExecutablePath(NULL, &sz); //function only returns "sz" if first arg is to small to hold value - buf = new char[++sz]; + _NSGetExecutablePath( + nullptr, &sz); // function only returns "sz" if first arg is to small to hold value - if (_NSGetExecutablePath(buf, &sz) == 0) { + if (const auto buf = new char[++sz]; _NSGetExecutablePath(buf, &sz) == 0) { char resolved[PATH_MAX]; char* path = realpath(buf, resolved); delete [] buf;