- MGR: Cache the local computer name in statics to avoid functions

that take awhile to execute.
        
    clientgui/
        MainDocument.cpp

svn path=/trunk/boinc/; revision=14686
This commit is contained in:
Rom Walton 2008-02-06 01:29:13 +00:00
parent d70d9f0183
commit b0869fb768
2 changed files with 19 additions and 2 deletions

View File

@ -1210,3 +1210,10 @@ David Feb 5 2008
clientgui/ clientgui/
BOINCBaseFrame.cpp BOINCBaseFrame.cpp
MainDocument.cpp MainDocument.cpp
Rom Feb 5 2008
- MGR: Cache the local computer name in statics to avoid functions
that take awhile to execute.
clientgui/
MainDocument.cpp

View File

@ -198,15 +198,25 @@ int CNetworkConnection::GetConnectingComputerName(wxString& strMachine) {
bool CNetworkConnection::IsComputerNameLocal(const wxString& strMachine) { bool CNetworkConnection::IsComputerNameLocal(const wxString& strMachine) {
static wxString strHostName = wxEmptyString;
static wxString strFullHostName = wxEmptyString;
if (strHostName.empty()) {
strHostName = ::wxGetHostName().Lower();
}
if (strFullHostName.empty()) {
strFullHostName = ::wxGetFullHostName().Lower();
}
if (strMachine.empty()) { if (strMachine.empty()) {
return true; return true;
} else if (wxT("localhost") == strMachine.Lower()) { } else if (wxT("localhost") == strMachine.Lower()) {
return true; return true;
} else if (wxT("localhost.localdomain") == strMachine.Lower()) { } else if (wxT("localhost.localdomain") == strMachine.Lower()) {
return true; return true;
} else if (::wxGetHostName().Lower() == strMachine.Lower()) { } else if (strHostName == strMachine.Lower()) {
return true; return true;
} else if (::wxGetFullHostName().Lower() == strMachine.Lower()) { } else if (strFullHostName == strMachine.Lower()) {
return true; return true;
} }
return false; return false;