1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 04:06:41 +02:00

Optimize much of the database code and serialize code.

This commit is contained in:
Adam
2012-12-13 06:12:56 -05:00
parent 76ba147c22
commit c1077faa28
60 changed files with 1203 additions and 1057 deletions
+13 -9
View File
@@ -82,29 +82,33 @@ BotInfo::~BotInfo()
BotListByUID->erase(this->uid);
}
Serialize::Data BotInfo::Serialize() const
void BotInfo::Serialize(Serialize::Data &data) const
{
Serialize::Data data;
data["nick"].SetMax(64)/*XXX*/ << this->nick;
data["nick"] << this->nick;
data["user"] << this->ident;
data["host"] << this->host;
data["realname"] << this->realname;
data["created"] << this->created;
data["flags"] << this->ToString();
return data;
}
Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
{
Anope::string nick, user, host, realname, flags;
data["nick"] >> nick;
data["user"] >> user;
data["host"] >> host;
data["realname"] >> realname;
data["flags"] >> flags;
BotInfo *bi;
if (obj)
bi = anope_dynamic_static_cast<BotInfo *>(obj);
else if (!(bi = BotInfo::Find(data["nick"].astr())))
bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr());
else if (!(bi = BotInfo::Find(nick)))
bi = new BotInfo(nick, user, host, realname);
data["created"] >> bi->created;
bi->FromString(data["flags"].astr());
bi->FromString(flags);
return bi;
}