I found these codes are for debugging only, but they are not excluded if _DEBUG is not set, so in order to:
- Remove unused variable to save spaces. (Function could be omitted by a linker)
- ***** IMPORTANT *****
Use inline function returning a constant to help compiler omit more code.
After applying this patch, the final exe could be reduce by 50~60kb.
diff --git a/srchybrid/PPgDebug.cpp b/srchybrid/PPgDebug.cpp index 9568b7e..80dc3fa 100644 --- a/srchybrid/PPgDebug.cpp +++ b/srchybrid/PPgDebug.cpp @@ -15,6 +15,7 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "stdafx.h" +#if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) #include "emule.h" #include "PPgDebug.h" #include "Preferences.h" @@ -239,3 +240,5 @@ BOOL CPPgDebug::onhelpInfo(HELPINFO* /*pHelpInfo*/) onhelp(); return TRUE; } + +#endif \ No newline at end of file diff --git a/srchybrid/PPgDebug.h b/srchybrid/PPgDebug.h index 1076c9c..db4f170 100644 --- a/srchybrid/PPgDebug.h +++ b/srchybrid/PPgDebug.h @@ -1,4 +1,5 @@ #pragma once +#if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) #include "TreeOptionsCtrlEx.h" #define MAX_DETAIL_ITEMS 7 @@ -46,3 +47,4 @@ protected: afx_msg void onhelp(); afx_msg BOOL onhelpInfo(HELPINFO* pHelpInfo); }; +#endif diff --git a/srchybrid/Preferences.cpp b/srchybrid/Preferences.cpp index 2ebe533..7ac8cf4 100644 --- a/srchybrid/Preferences.cpp +++ b/srchybrid/Preferences.cpp @@ -309,9 +309,6 @@ bool CPreferences::m_bLogA4AF; // ZZ:DownloadManager bool CPreferences::m_bLogUlDlEvents; #if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) bool CPreferences::m_bUseDebugDevice = true; -#else -bool CPreferences::m_bUseDebugDevice = false; -#endif int CPreferences::m_iDebugServerTCPLevel; int CPreferences::m_iDebugServerUDPLevel; int CPreferences::m_iDebugServerSourcesLevel; @@ -320,6 +317,7 @@ int CPreferences::m_iDebugClientTCPLevel; int CPreferences::m_iDebugClientUDPLevel; int CPreferences::m_iDebugClientKadUDPLevel; int CPreferences::m_iDebugSearchResultDetailLevel; +#endif bool CPreferences::m_bupdatequeuelist; bool CPreferences::m_bManualAddedServersHighPriority; bool CPreferences::m_btransferfullchunks; @@ -2217,16 +2215,6 @@ void CPreferences::LoadPreferences() m_iDebugClientUDPLevel = ini.GetInt(L"DebugClientUDP", 0); m_iDebugClientKadUDPLevel = ini.GetInt(L"DebugClientKadUDP", 0); m_iDebugSearchResultDetailLevel = ini.GetInt(L"DebugSearchResultDetailLevel", 0); -#else - // for normal release builds ensure that those options are all turned off - m_iDebugServerTCPLevel = 0; - m_iDebugServerUDPLevel = 0; - m_iDebugServerSourcesLevel = 0; - m_iDebugServerSearchesLevel = 0; - m_iDebugClientTCPLevel = 0; - m_iDebugClientUDPLevel = 0; - m_iDebugClientKadUDPLevel = 0; - m_iDebugSearchResultDetailLevel = 0; #endif m_bpreviewprio=ini.GetBool(L"PreviewPrio",false); diff --git a/srchybrid/Preferences.h b/srchybrid/Preferences.h index dc08fd5..bfbac14 100644 --- a/srchybrid/Preferences.h +++ b/srchybrid/Preferences.h @@ -391,6 +391,7 @@ public: static bool m_bLogFileSaving; static bool m_bLogA4AF; // ZZ:DownloadManager static bool m_bLogUlDlEvents; +#if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) static bool m_bUseDebugDevice; static int m_iDebugServerTCPLevel; static int m_iDebugServerUDPLevel; @@ -400,6 +401,7 @@ public: static int m_iDebugClientUDPLevel; static int m_iDebugClientKadUDPLevel; static int m_iDebugSearchResultDetailLevel; +#endif static bool m_bupdatequeuelist; static bool m_bManualAddedServersHighPriority; static bool m_btransferfullchunks; @@ -1317,6 +1319,7 @@ public: static bool GetLogA4AF() {return m_bVerbose && m_bLogA4AF;} // ZZ:DownloadManager static bool GetLogUlDlEvents() {return m_bVerbose && m_bLogUlDlEvents;} static bool GetLogKadSecurityEvents() {return m_bVerbose && true;} +#if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) static bool GetUseDebugDevice() {return m_bUseDebugDevice;} static int GetDebugServerTCPLevel() {return m_iDebugServerTCPLevel;} static int GetDebugServerUDPLevel() {return m_iDebugServerUDPLevel;} @@ -1326,6 +1329,18 @@ public: static int GetDebugClientUDPLevel() {return m_iDebugClientUDPLevel;} static int GetDebugClientKadUDPLevel() {return m_iDebugClientKadUDPLevel;} static int GetDebugSearchResultDetailLevel() {return m_iDebugSearchResultDetailLevel;} +#else + // for normal release builds these options are all turned off + inline static bool GetUseDebugDevice() {return false;} + inline static int GetDebugServerTCPLevel() {return 0;} + inline static int GetDebugServerUDPLevel() {return 0;} + inline static int GetDebugServerSourcesLevel() {return 0;} + inline static int GetDebugServerSearchesLevel() {return 0;} + inline static int GetDebugClientTCPLevel() {return 0;} + inline static int GetDebugClientUDPLevel() {return 0;} + inline static int GetDebugClientKadUDPLevel() {return 0;} + inline static int GetDebugSearchResultDetailLevel() {return 0;} +#endif static int GetVerboseLogPriority() {return m_byLogLevel;} // Firewall settings
This post has been edited by YumeYao: 10 January 2013 - 09:28 AM