From 4fc6c73dd918d29c81a879f535c3df92d895fed6 Mon Sep 17 00:00:00 2001 From: sehraf Date: Mon, 7 Sep 2015 23:40:52 +0200 Subject: [PATCH] replaced some ifs with switch --- libretroshare/src/pqi/p3linkmgr.cc | 9 +++++++-- libretroshare/src/pqi/p3peermgr.cc | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index c10f2472b..38323cbc2 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -2026,11 +2026,16 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, peerConnectAddress pca; pca.addr = proxy_addr; - if (mPeerMgr->hiddenDomainToHiddenType(domain_addr) == RS_HIDDEN_TYPE_I2P) + switch (mPeerMgr->hiddenDomainToHiddenType(domain_addr)) { + case RS_HIDDEN_TYPE_I2P: pca.type = RS_NET_CONN_TCP_HIDDEN_I2P; - else + break; + case RS_HIDDEN_TYPE_TOR: + default: /* default tor */ pca.type = RS_NET_CONN_TCP_HIDDEN_TOR; + break; + } //for the delay, we add a random time and some more time when the friend list is big pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY; diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 3801355d6..c40582aca 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -637,11 +637,16 @@ bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_stor domain_addr = it->second.hiddenDomain; domain_port = it->second.hiddenPort; - if(it->second.hiddenType == RS_HIDDEN_TYPE_I2P) + switch (it->second.hiddenType) { + case RS_HIDDEN_TYPE_I2P: proxy_addr = mProxyServerAddressI2P; - else + break; + case RS_HIDDEN_TYPE_TOR: + default: /* default tor */ proxy_addr = mProxyServerAddressTor; + break; + } return true; }