linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04615
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2633: get geo strings by ref since they are cached
------------------------------------------------------------
revno: 2633
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2011-10-11 20:38:23 +0200
message:
get geo strings by ref since they are cached
modified:
dcpp/GeoIP.cpp
dcpp/GeoIP.h
dcpp/GeoManager.cpp
dcpp/GeoManager.h
dcpp/OnlineUser.h
dcpp/User.cpp
win32/SearchFrame.cpp
win32/TransferView.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/GeoIP.cpp'
--- dcpp/GeoIP.cpp 2011-10-10 17:43:39 +0000
+++ dcpp/GeoIP.cpp 2011-10-11 18:38:23 +0000
@@ -30,11 +30,9 @@
namespace dcpp {
GeoIP::GeoIP(string&& path) : geo(0), path(forward<string>(path)) {
- if(File::getSize(path) <= 0 && !decompress()) {
- return;
+ if(File::getSize(path) > 0 || decompress()) {
+ open();
}
-
- open();
}
GeoIP::~GeoIP() {
@@ -42,7 +40,7 @@
close();
}
-string GeoIP::getCountry(const string& ip) const {
+const string& GeoIP::getCountry(const string& ip) const {
Lock l(cs);
if(geo) {
auto id = (v6() ? GeoIP_id_by_addr_v6 : GeoIP_id_by_addr)(geo, ip.c_str());
=== modified file 'dcpp/GeoIP.h'
--- dcpp/GeoIP.h 2011-10-10 17:43:39 +0000
+++ dcpp/GeoIP.h 2011-10-11 18:38:23 +0000
@@ -36,7 +36,7 @@
explicit GeoIP(string&& path);
~GeoIP();
- string getCountry(const string& ip) const;
+ const string& getCountry(const string& ip) const;
void update();
void rebuild();
=== modified file 'dcpp/GeoManager.cpp'
--- dcpp/GeoManager.cpp 2011-10-08 15:21:54 +0000
+++ dcpp/GeoManager.cpp 2011-10-11 18:38:23 +0000
@@ -49,11 +49,11 @@
geo4.reset();
}
-string GeoManager::getCountry(const string& ip, int flags) {
+const string& GeoManager::getCountry(const string& ip, int flags) {
if(!ip.empty()) {
if((flags & V6) && geo6.get()) {
- auto ret = geo6->getCountry(ip);
+ const auto& ret = geo6->getCountry(ip);
if(!ret.empty())
return ret;
}
=== modified file 'dcpp/GeoManager.h'
--- dcpp/GeoManager.h 2011-10-08 15:21:54 +0000
+++ dcpp/GeoManager.h 2011-10-11 18:38:23 +0000
@@ -46,7 +46,7 @@
enum { V6 = 1 << 1, V4 = 1 << 2 };
/** Map an IP address to a country. The flags specify which database(s) to look into. */
- string getCountry(const string& ip, int flags = V6 | V4);
+ const string& getCountry(const string& ip, int flags = V6 | V4);
static string getDbPath(bool v6);
=== modified file 'dcpp/OnlineUser.h'
--- dcpp/OnlineUser.h 2011-09-30 11:33:12 +0000
+++ dcpp/OnlineUser.h 2011-10-11 18:38:23 +0000
@@ -81,7 +81,7 @@
string getTag() const;
string getApplication() const;
string getConnection() const;
- string getCountry() const;
+ const string& getCountry() const;
bool supports(const string& name) const;
bool isHub() const { return isClientType(CT_HUB) || isSet("HU"); }
bool isOp() const { return isClientType(CT_OP) || isClientType(CT_SU) || isClientType(CT_OWNER) || isSet("OP"); }
=== modified file 'dcpp/User.cpp'
--- dcpp/User.cpp 2011-10-08 15:21:54 +0000
+++ dcpp/User.cpp 2011-10-11 18:38:23 +0000
@@ -143,7 +143,7 @@
return get("CO");
}
-string Identity::getCountry() const {
+const string& Identity::getCountry() const {
bool v6 = !getIp6().empty();
return GeoManager::getInstance()->getCountry(v6 ? getIp6() : getIp4(), v6 ? GeoManager::V6 : GeoManager::V4);
}
=== modified file 'win32/SearchFrame.cpp'
--- win32/SearchFrame.cpp 2011-10-08 15:21:54 +0000
+++ win32/SearchFrame.cpp 2011-10-11 18:38:23 +0000
@@ -488,7 +488,7 @@
columns[COLUMN_CONNECTION] = Text::toT(ClientManager::getInstance()->getConnection(sr->getUser()->getCID()));
columns[COLUMN_SLOTS] = Text::toT(sr->getSlotString());
const auto& ip = sr->getIP();
- auto country = GeoManager::getInstance()->getCountry(ip);
+ const auto& country = GeoManager::getInstance()->getCountry(ip);
columns[COLUMN_IP] = Text::toT(country.empty() ? ip : str(F_("%1% (%2%)") % country % ip));
columns[COLUMN_HUB] = Text::toT(sr->getHubName());
columns[COLUMN_CID] = Text::toT(sr->getUser()->getCID().toBase32());
=== modified file 'win32/TransferView.cpp'
--- win32/TransferView.cpp 2011-10-08 15:21:54 +0000
+++ win32/TransferView.cpp 2011-10-11 18:38:23 +0000
@@ -735,7 +735,7 @@
ui->setChunk(t->getPos(), t->getSize());
const UserConnection& uc = t->getUserConnection();
ui->setCipher(Text::toT(uc.getCipherName()));
- auto country = GeoManager::getInstance()->getCountry(uc.getRemoteIp());
+ const auto& country = GeoManager::getInstance()->getCountry(uc.getRemoteIp());
if(!country.empty())
ui->setCountry(Text::toT(country));
ui->setIP(Text::toT(uc.getRemoteIp()));