From b0869fb76887f4e30ed83260826efdc60d2694a3 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 6 Feb 2008 01:29:13 +0000 Subject: [PATCH] - 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 --- checkin_notes | 7 +++++++ clientgui/MainDocument.cpp | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/checkin_notes b/checkin_notes index ab0040a2ac..63b9b7fca8 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1210,3 +1210,10 @@ David Feb 5 2008 clientgui/ BOINCBaseFrame.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 diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index d7230ff735..5075ba2b32 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -198,15 +198,25 @@ int CNetworkConnection::GetConnectingComputerName(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()) { return true; } else if (wxT("localhost") == strMachine.Lower()) { return true; } else if (wxT("localhost.localdomain") == strMachine.Lower()) { return true; - } else if (::wxGetHostName().Lower() == strMachine.Lower()) { + } else if (strHostName == strMachine.Lower()) { return true; - } else if (::wxGetFullHostName().Lower() == strMachine.Lower()) { + } else if (strFullHostName == strMachine.Lower()) { return true; } return false;