Some bugfixes and performance enhancements

This commit is contained in:
Martijn Otto 2015-04-30 14:18:18 +02:00
parent 45deeaa754
commit fcc9522e16
10 changed files with 46 additions and 54 deletions

View File

@ -149,7 +149,7 @@ public:
* Get the byte value * Get the byte value
* @return value * @return value
*/ */
uint8_t value() uint8_t value() const
{ {
return _byte; return _byte;
} }

View File

@ -146,7 +146,7 @@ public:
* What is the state of the connection - is the protocol handshake completed? * What is the state of the connection - is the protocol handshake completed?
* @return bool * @return bool
*/ */
bool protocolOk() bool protocolOk() const
{ {
// must be busy doing the connection handshake, or already connected // must be busy doing the connection handshake, or already connected
return _state == state_handshake || _state == state_connected; return _state == state_handshake || _state == state_connected;
@ -209,7 +209,7 @@ public:
* The max frame size * The max frame size
* @return uint32_t * @return uint32_t
*/ */
uint32_t maxFrame() uint32_t maxFrame() const
{ {
return _maxFrame; return _maxFrame;
} }
@ -218,7 +218,7 @@ public:
* The max payload size for body frames * The max payload size for body frames
* @return uint32_t * @return uint32_t
*/ */
uint32_t maxPayload() uint32_t maxPayload() const
{ {
// 8 bytes for header and end-of-frame byte // 8 bytes for header and end-of-frame byte
return _maxFrame - 8; return _maxFrame - 8;

View File

@ -176,7 +176,7 @@ public:
/** /**
* Cast to a boolean * Cast to a boolean
*/ */
operator bool () operator bool () const
{ {
return !_failed; return !_failed;
} }

View File

@ -162,7 +162,7 @@ public:
* @param value * @param value
* @return FieldProxy * @return FieldProxy
*/ */
FieldProxy& operator=(const DecimalField value) FieldProxy& operator=(const DecimalField &value)
{ {
// assign value and allow chaining // assign value and allow chaining
_source->set(_index, DecimalField(value)); _source->set(_index, DecimalField(value));

View File

@ -258,7 +258,7 @@ public:
* This is an alias for retrieving the delivery mode and checking if it is set to 2 * This is an alias for retrieving the delivery mode and checking if it is set to 2
* @return bool * @return bool
*/ */
bool persistent() bool persistent() const
{ {
return hasDeliveryMode() && deliveryMode() == 2; return hasDeliveryMode() && deliveryMode() == 2;
} }

View File

@ -60,7 +60,7 @@ public:
* Check if the object is valid * Check if the object is valid
* @return bool * @return bool
*/ */
bool valid() bool valid() const
{ {
return _watchable != nullptr; return _watchable != nullptr;
} }

View File

@ -103,10 +103,10 @@ public:
} }
/** /**
* Return whether to acknowledgement multiple messages * Return whether to acknowledge multiple messages
* @return bool * @return bool
*/ */
bool multiple() bool multiple() const
{ {
return _multiple.get(0); return _multiple.get(0);
} }

View File

@ -95,7 +95,7 @@ public:
* Return whether to acknowledgement multiple messages * Return whether to acknowledgement multiple messages
* @return bool * @return bool
*/ */
bool multiple() bool multiple() const
{ {
return _bits.get(0); return _bits.get(0);
} }
@ -104,7 +104,7 @@ public:
* Should the message be put back in the queue? * Should the message be put back in the queue?
* @return bool * @return bool
*/ */
bool requeue() bool requeue() const
{ {
return _bits.get(1); return _bits.get(1);
} }

View File

@ -22,12 +22,6 @@ private:
*/ */
const char *_payload; const char *_payload;
/**
* Size of the payload
* @var uint64_t
*/
uint32_t _size;
protected: protected:
/** /**
* Encode a body frame to a string buffer * Encode a body frame to a string buffer
@ -53,8 +47,7 @@ public:
*/ */
BodyFrame(uint16_t channel, const char *payload, uint32_t size) : BodyFrame(uint16_t channel, const char *payload, uint32_t size) :
ExtFrame(channel, size), ExtFrame(channel, size),
_payload(payload), _payload(payload)
_size(size)
{} {}
/** /**
@ -65,8 +58,7 @@ public:
*/ */
BodyFrame(ReceivedFrame& frame) : BodyFrame(ReceivedFrame& frame) :
ExtFrame(frame), ExtFrame(frame),
_payload(frame.nextData(frame.payloadSize())), _payload(frame.nextData(frame.payloadSize()))
_size(frame.payloadSize())
{} {}
/** /**

View File

@ -81,7 +81,7 @@ public:
* @param failingClass id of the failing class if applicable * @param failingClass id of the failing class if applicable
* @param failingMethod id of the failing method if applicable * @param failingMethod id of the failing method if applicable
*/ */
ConnectionCloseFrame(uint16_t code, const std::string text, uint16_t failingClass = 0, uint16_t failingMethod = 0) : ConnectionCloseFrame(uint16_t code, const std::string &text, uint16_t failingClass = 0, uint16_t failingMethod = 0) :
ConnectionFrame(text.length() + 7), // 1 for extra string byte, 2 for each uint16 ConnectionFrame(text.length() + 7), // 1 for extra string byte, 2 for each uint16
_code(code), _code(code),
_text(text), _text(text),