From e49b1af8f15f0c498fbacc91d9f582861173623a Mon Sep 17 00:00:00 2001 From: "Carl C. Trieloff" Date: Thu, 29 May 2008 20:06:03 +0000 Subject: 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 --- qpid/cpp/src/qpid/framing/FrameSet.cpp | 14 ++++++++++---- qpid/cpp/src/qpid/framing/FrameSet.h | 2 ++ qpid/cpp/src/tests/MessageBuilderTest.cpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/src') 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()); - return sum.getSize(); + if (recalculateSize) + { + SumBodySize sum; + map_if(sum, TypeFilter()); + 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 Frames; const SequenceNumber id; Frames parts; + mutable uint64_t contentSize; + mutable bool recalculateSize; public: typedef boost::shared_ptr 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()); } }; -- cgit v1.2.1