From b338e29fd3eaf700f8c8360aa0310048ba941d54 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:12:46 +0200 Subject: 3.19 --- shared/dll_loader.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'shared/dll_loader.cpp') diff --git a/shared/dll_loader.cpp b/shared/dll_loader.cpp index e942a168..029cabc5 100644 --- a/shared/dll_loader.cpp +++ b/shared/dll_loader.cpp @@ -20,20 +20,18 @@ public: HMODULE getHandle(const std::wstring& libraryName) { - HandleMap::const_iterator foundEntry = handles.find(libraryName); - if (foundEntry == handles.end()) - { - if (libraryName.empty()) - return ::GetModuleHandle(NULL); //return handle to calling executable + if (libraryName.empty()) + return ::GetModuleHandle(NULL); //return handle to calling executable - HMODULE newHandle = ::LoadLibrary(libraryName.c_str()); - if (newHandle != NULL) - handles.insert(std::make_pair(libraryName, newHandle)); + HandleMap::const_iterator iter = handles.find(libraryName); + if (iter != handles.end()) + return iter->second; - return newHandle; - } - else - return foundEntry->second; + HMODULE newHandle = ::LoadLibrary(libraryName.c_str()); + if (newHandle != NULL) + handles.insert(std::make_pair(libraryName, newHandle)); + + return newHandle; } private: @@ -56,11 +54,7 @@ private: FARPROC util::loadSymbol(const std::wstring& libraryName, const std::string& functionName) { const HMODULE libHandle = DllHandler::getInstance().getHandle(libraryName); - - if (libHandle != NULL) - return ::GetProcAddress(libHandle, functionName.c_str()); - else - return NULL; + return libHandle != NULL ? ::GetProcAddress(libHandle, functionName.c_str()) : NULL; } -- cgit