summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/framing/FrameSet.cpp14
-rw-r--r--cpp/src/qpid/framing/FrameSet.h2
-rw-r--r--cpp/src/tests/MessageBuilderTest.cpp2
3 files changed, 13 insertions, 5 deletions
diff --git a/cpp/src/qpid/framing/FrameSet.cpp b/cpp/src/qpid/framing/FrameSet.cpp
index e6f15f2c4e..f5fe02c5ba 100644
--- a/cpp/src/qpid/framing/FrameSet.cpp
+++ b/cpp/src/qpid/framing/FrameSet.cpp
@@ -28,11 +28,12 @@
using namespace qpid::framing;
using namespace boost;
-FrameSet::FrameSet(const SequenceNumber& _id) : id(_id) {parts.reserve(4);}
+FrameSet::FrameSet(const SequenceNumber& _id) : id(_id),contentSize(0),recalculateSize(true) {parts.reserve(4);}
void FrameSet::append(const AMQFrame& part)
{
parts.push_back(part);
+ recalculateSize = true;
}
bool FrameSet::isComplete() const
@@ -63,9 +64,14 @@ AMQHeaderBody* FrameSet::getHeaders()
uint64_t FrameSet::getContentSize() const
{
- SumBodySize sum;
- map_if(sum, TypeFilter<CONTENT_BODY>());
- return sum.getSize();
+ if (recalculateSize)
+ {
+ SumBodySize sum;
+ map_if(sum, TypeFilter<CONTENT_BODY>());
+ contentSize = sum.getSize();
+ recalculateSize = false;
+ }
+ return contentSize;
}
void FrameSet::getContent(std::string& out) const {
diff --git a/cpp/src/qpid/framing/FrameSet.h b/cpp/src/qpid/framing/FrameSet.h
index 454d292d9d..d23cb717c9 100644
--- a/cpp/src/qpid/framing/FrameSet.h
+++ b/cpp/src/qpid/framing/FrameSet.h
@@ -38,6 +38,8 @@ class FrameSet
typedef std::vector<AMQFrame> Frames;
const SequenceNumber id;
Frames parts;
+ mutable uint64_t contentSize;
+ mutable bool recalculateSize;
public:
typedef boost::shared_ptr<FrameSet> shared_ptr;
diff --git a/cpp/src/tests/MessageBuilderTest.cpp b/cpp/src/tests/MessageBuilderTest.cpp
index 7149ec50c7..69e2ec1c1e 100644
--- a/cpp/src/tests/MessageBuilderTest.cpp
+++ b/cpp/src/tests/MessageBuilderTest.cpp
@@ -216,7 +216,7 @@ class MessageBuilderTest : public CppUnit::TestCase
CPPUNIT_ASSERT(store.expectationsMet());
//were the content frames dropped?
- CPPUNIT_ASSERT_EQUAL((uint64_t) 0, builder.getMessage()->contentSize());
+ CPPUNIT_ASSERT(!builder.getMessage()->isContentLoaded());
}
};