summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorCarl C. Trieloff <cctrieloff@apache.org>2008-05-29 20:06:03 +0000
committerCarl C. Trieloff <cctrieloff@apache.org>2008-05-29 20:06:03 +0000
commite49b1af8f15f0c498fbacc91d9f582861173623a (patch)
tree0d968616487d6386036004c076a9cea7a06c548e /qpid/cpp/src
parent63bea84277fff96d1082049bf06b35ae8824c37d (diff)
downloadqpid-python-e49b1af8f15f0c498fbacc91d9f582861173623a.tar.gz
Performnace fix, improves 6-8% on high core count machines.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@661455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/framing/FrameSet.cpp14
-rw-r--r--qpid/cpp/src/qpid/framing/FrameSet.h2
-rw-r--r--qpid/cpp/src/tests/MessageBuilderTest.cpp2
3 files changed, 13 insertions, 5 deletions
diff --git a/qpid/cpp/src/qpid/framing/FrameSet.cpp b/qpid/cpp/src/qpid/framing/FrameSet.cpp
index e6f15f2c4e..f5fe02c5ba 100644
--- a/qpid/cpp/src/qpid/framing/FrameSet.cpp
+++ b/qpid/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/qpid/cpp/src/qpid/framing/FrameSet.h b/qpid/cpp/src/qpid/framing/FrameSet.h
index 454d292d9d..d23cb717c9 100644
--- a/qpid/cpp/src/qpid/framing/FrameSet.h
+++ b/qpid/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/qpid/cpp/src/tests/MessageBuilderTest.cpp b/qpid/cpp/src/tests/MessageBuilderTest.cpp
index 7149ec50c7..69e2ec1c1e 100644
--- a/qpid/cpp/src/tests/MessageBuilderTest.cpp
+++ b/qpid/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());
}
};