From 35c0a4a6b7cc8f96332a13e1ae952ddb1abedbc0 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 28 Jul 2013 05:10:06 +0200 Subject: [PATCH] Avoid redundant per-frame calls to getDbProp in CNetManager --- code/ryzom/client/src/net_manager.cpp | 18 ++++++++++++------ code/ryzom/client/src/net_manager.h | 8 ++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index f9a5628ca..6e45c4fb4 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -3861,22 +3861,28 @@ bool CNetManager::update() CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false); + CCDBNodeLeaf *node = m_PingLeaf ? &*m_PingLeaf + : (m_PingLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false)); if (node) node->setValue32(getPing()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false); + node = m_UploadLeaf ? &*m_UploadLeaf + : (m_UploadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false)); if (node) node->setValue32((sint32)(getMeanUpload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false); + node = m_DownloadLeaf ? &*m_DownloadLeaf + : (m_DownloadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false)); if (node) node->setValue32((sint32)(getMeanDownload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false); + node = m_PacketLostLeaf ? &* m_PacketLostLeaf + : (m_PacketLostLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false)); if (node) node->setValue32((sint32)getMeanPacketLoss()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false); + node = m_ServerStateLeaf ? &*m_ServerStateLeaf + : (m_ServerStateLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false)); if (node) node->setValue32((sint32)getConnectionState()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false); + node = m_ConnectionQualityLeaf ? &*m_ConnectionQualityLeaf + : (m_ConnectionQualityLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false)); if (node) node->setValue32((sint32)getConnectionQuality()); } diff --git a/code/ryzom/client/src/net_manager.h b/code/ryzom/client/src/net_manager.h index 9fef4bc1d..06d6a7621 100644 --- a/code/ryzom/client/src/net_manager.h +++ b/code/ryzom/client/src/net_manager.h @@ -43,6 +43,7 @@ void initializeNetwork(); namespace NLMISC { class CBitMemStream; + class CCDBNodeLeaf; }; @@ -126,6 +127,13 @@ public: protected: bool _IsReplayStarting; #endif + + NLMISC::CRefPtr m_PingLeaf; + NLMISC::CRefPtr m_UploadLeaf; + NLMISC::CRefPtr m_DownloadLeaf; + NLMISC::CRefPtr m_PacketLostLeaf; + NLMISC::CRefPtr m_ServerStateLeaf; + NLMISC::CRefPtr m_ConnectionQualityLeaf; };