change createCopy in packet to take const &

This commit is contained in:
Stephen Birarda 2015-07-09 11:23:44 -07:00
parent 659f6742c6
commit bd9b42bd4c
4 changed files with 8 additions and 10 deletions

View file

@ -37,9 +37,8 @@ std::unique_ptr<NLPacket> NLPacket::create(PacketType::Value type, int64_t size)
return std::unique_ptr<NLPacket>(new NLPacket(type, size)); return std::unique_ptr<NLPacket>(new NLPacket(type, size));
} }
std::unique_ptr<NLPacket> NLPacket::createCopy(const std::unique_ptr<NLPacket>& other) { std::unique_ptr<NLPacket> NLPacket::createCopy(const NLPacket& other) {
Q_ASSERT(other); return std::unique_ptr<NLPacket>(new NLPacket(other));
return std::unique_ptr<NLPacket>(new NLPacket(*other));
} }
NLPacket::NLPacket(PacketType::Value type, int64_t size) : Packet(type, localHeaderSize(type) + size) { NLPacket::NLPacket(PacketType::Value type, int64_t size) : Packet(type, localHeaderSize(type) + size) {

View file

@ -19,7 +19,7 @@ class NLPacket : public Packet {
public: public:
static std::unique_ptr<NLPacket> create(PacketType::Value type, int64_t size = -1); static std::unique_ptr<NLPacket> create(PacketType::Value type, int64_t size = -1);
// Provided for convenience, try to limit use // Provided for convenience, try to limit use
static std::unique_ptr<NLPacket> createCopy(const std::unique_ptr<NLPacket>& other); static std::unique_ptr<NLPacket> createCopy(const NLPacket& other);
static int64_t localHeaderSize(PacketType::Value type); static int64_t localHeaderSize(PacketType::Value type);
static int64_t maxPayloadSize(PacketType::Value type); static int64_t maxPayloadSize(PacketType::Value type);

View file

@ -38,9 +38,8 @@ std::unique_ptr<Packet> Packet::create(PacketType::Value type, qint64 size) {
return std::unique_ptr<Packet>(new Packet(type, size)); return std::unique_ptr<Packet>(new Packet(type, size));
} }
std::unique_ptr<Packet> Packet::createCopy(const std::unique_ptr<Packet>& other) { std::unique_ptr<Packet> Packet::createCopy(const Packet& other) {
Q_ASSERT(other); return std::unique_ptr<Packet>(new Packet(other));
return std::unique_ptr<Packet>(new Packet(*other));
} }
qint64 Packet::totalHeadersSize() const { qint64 Packet::totalHeadersSize() const {

View file

@ -25,7 +25,7 @@ public:
static std::unique_ptr<Packet> create(PacketType::Value type, int64_t size = -1); static std::unique_ptr<Packet> create(PacketType::Value type, int64_t size = -1);
// Provided for convenience, try to limit use // Provided for convenience, try to limit use
static std::unique_ptr<Packet> createCopy(const std::unique_ptr<Packet>& other); static std::unique_ptr<Packet> createCopy(const Packet& other);
static qint64 localHeaderSize(PacketType::Value type); static qint64 localHeaderSize(PacketType::Value type);
static qint64 maxPayloadSize(PacketType::Value type); static qint64 maxPayloadSize(PacketType::Value type);