switched extension handshake parsing over to use lazy_bdecode for improved performance

This commit is contained in:
Arvid Norberg
2008-07-01 08:04:12 +00:00
parent 9c84908bb9
commit 10f5418ce7
7 changed files with 56 additions and 72 deletions

View File

@@ -278,15 +278,16 @@ namespace libtorrent { namespace
}
// called when the extension handshake from the other end is received
virtual bool on_extension_handshake(entry const& h)
virtual bool on_extension_handshake(lazy_entry const& h)
{
m_message_index = 0;
entry const* messages = h.find_key("m");
if (!messages || messages->type() != entry::dictionary_t) return false;
if (h.type() != lazy_entry::dict_t) return false;
lazy_entry const* messages = h.dict_find("m");
if (!messages || messages->type() != lazy_entry::dict_t) return false;
entry const* index = messages->find_key("LT_metadata");
if (!index || index->type() != entry::int_t) return false;
m_message_index = int(index->integer());
int index = messages->dict_find_int_value("LT_metadata", -1);
if (index == -1) return false;
m_message_index = index;
return true;
}