mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
use flat_map for smaller tables
This commit is contained in:
parent
18b6ba80f2
commit
518e53a61c
|
@ -218,7 +218,7 @@ namespace transport
|
||||||
|
|
||||||
void SSUServer::AddRelay (uint32_t tag, std::shared_ptr<SSUSession> relay)
|
void SSUServer::AddRelay (uint32_t tag, std::shared_ptr<SSUSession> relay)
|
||||||
{
|
{
|
||||||
m_Relays[tag] = relay;
|
m_Relays.emplace (tag, relay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUServer::RemoveRelay (uint32_t tag)
|
void SSUServer::RemoveRelay (uint32_t tag)
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace transport
|
||||||
std::list<boost::asio::ip::udp::endpoint> m_Introducers, m_IntroducersV6; // introducers we are connected to
|
std::list<boost::asio::ip::udp::endpoint> m_Introducers, m_IntroducersV6; // introducers we are connected to
|
||||||
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > m_Sessions, m_SessionsV6;
|
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > m_Sessions, m_SessionsV6;
|
||||||
std::map<uint32_t, std::shared_ptr<SSUSession> > m_Relays; // we are introducer
|
std::map<uint32_t, std::shared_ptr<SSUSession> > m_Relays; // we are introducer
|
||||||
std::map<uint32_t, PeerTest> m_PeerTests; // nonce -> creation time in milliseconds
|
boost::container::flat_map<uint32_t, PeerTest> m_PeerTests; // nonce -> creation time in milliseconds
|
||||||
|
|
||||||
i2p::util::MemoryPool<Fragment> m_FragmentsPool;
|
i2p::util::MemoryPool<Fragment> m_FragmentsPool;
|
||||||
i2p::util::MemoryPool<IncompleteMessage> m_IncompleteMessagesPool;
|
i2p::util::MemoryPool<IncompleteMessage> m_IncompleteMessagesPool;
|
||||||
|
|
|
@ -310,7 +310,7 @@ namespace transport
|
||||||
if (m_SentMessages.empty ()) // schedule resend at first message only
|
if (m_SentMessages.empty ()) // schedule resend at first message only
|
||||||
ScheduleResend ();
|
ScheduleResend ();
|
||||||
|
|
||||||
auto ret = m_SentMessages.insert (std::make_pair (msgID, m_Session.GetServer ().GetSentMessagesPool ().AcquireShared ()));
|
auto ret = m_SentMessages.emplace (msgID, m_Session.GetServer ().GetSentMessagesPool ().AcquireShared ());
|
||||||
auto& sentMessage = ret.first->second;
|
auto& sentMessage = ret.first->second;
|
||||||
if (ret.second)
|
if (ret.second)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/container/flat_map.hpp>
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
|
@ -123,9 +123,9 @@ namespace transport
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SSUSession& m_Session;
|
SSUSession& m_Session;
|
||||||
std::unordered_map<uint32_t, std::shared_ptr<IncompleteMessage> > m_IncompleteMessages;
|
boost::container::flat_map<uint32_t, std::shared_ptr<IncompleteMessage> > m_IncompleteMessages;
|
||||||
std::unordered_map<uint32_t, std::shared_ptr<SentMessage> > m_SentMessages;
|
boost::container::flat_map<uint32_t, std::shared_ptr<SentMessage> > m_SentMessages;
|
||||||
std::unordered_map<uint32_t, uint64_t> m_ReceivedMessages; // msgID -> timestamp in seconds
|
boost::container::flat_map<uint32_t, uint64_t> m_ReceivedMessages; // msgID -> timestamp in seconds
|
||||||
boost::asio::deadline_timer m_ResendTimer;
|
boost::asio::deadline_timer m_ResendTimer;
|
||||||
int m_MaxPacketSize, m_PacketSize;
|
int m_MaxPacketSize, m_PacketSize;
|
||||||
i2p::I2NPMessagesHandler m_Handler;
|
i2p::I2NPMessagesHandler m_Handler;
|
||||||
|
|
Loading…
Reference in a new issue