Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 3160 invoked from network); 10 Jun 2007 23:24:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2007 23:24:21 -0000 Received: (qmail 28433 invoked by uid 500); 10 Jun 2007 23:24:25 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 28405 invoked by uid 500); 10 Jun 2007 23:24:25 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 28396 invoked by uid 99); 10 Jun 2007 23:24:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jun 2007 16:24:25 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jun 2007 16:24:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C8DAF1A981A; Sun, 10 Jun 2007 16:24:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r545967 - in /activemq/activemq-cpp/trunk/src/main/activemq: connector/openwire/commands/ActiveMQBytesMessage.cpp connector/stomp/StompFrame.h io/BlockingByteArrayInputStream.cpp io/ByteArrayOutputStream.cpp Date: Sun, 10 Jun 2007 23:24:00 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070610232400.C8DAF1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sun Jun 10 16:23:59 2007 New Revision: 545967 URL: http://svn.apache.org/viewvc?view=rev&rev=545967 Log: https://issues.apache.org/activemq/browse/AMQCPP-93 Slight tweaks for performance, Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h activemq/activemq-cpp/trunk/src/main/activemq/io/BlockingByteArrayInputStream.cpp activemq/activemq-cpp/trunk/src/main/activemq/io/ByteArrayOutputStream.cpp Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp?view=diff&rev=545967&r1=545966&r2=545967 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp Sun Jun 10 16:23:59 2007 @@ -50,9 +50,8 @@ try{ clearBody(); - for( size_t i = 0; i < numBytes; ++i ) { - getContent().push_back( buffer[i] ); - } + std::vector& content = getContent(); + content.insert( content.end(), buffer, buffer + numBytes ); } AMQ_CATCH_RETHROW( exceptions::ActiveMQException ) AMQ_CATCHALL_THROW( exceptions::ActiveMQException ) Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h?view=diff&rev=545967&r1=545966&r2=545967 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h Sun Jun 10 16:23:59 2007 @@ -123,10 +123,7 @@ body.clear(); // Copy data to internal buffer. - for( std::size_t ix = 0; ix < numBytes; ++ix ) - { - body.push_back(bytes[ix]); - } + body.insert( body.end(), bytes, bytes + numBytes ); } private: Modified: activemq/activemq-cpp/trunk/src/main/activemq/io/BlockingByteArrayInputStream.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/io/BlockingByteArrayInputStream.cpp?view=diff&rev=545967&r1=545966&r2=545967 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/io/BlockingByteArrayInputStream.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/io/BlockingByteArrayInputStream.cpp Sun Jun 10 16:23:59 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "BlockingByteArrayInputStream.h" #include @@ -30,10 +30,10 @@ } //////////////////////////////////////////////////////////////////////////////// -BlockingByteArrayInputStream::BlockingByteArrayInputStream( +BlockingByteArrayInputStream::BlockingByteArrayInputStream( const unsigned char* buffer, std::size_t bufferSize ){ - + closing = false; setByteArray( buffer, bufferSize ); } @@ -46,19 +46,16 @@ void BlockingByteArrayInputStream::setByteArray( const unsigned char* lbuffer, std::size_t lbufferSize ){ synchronized( this ){ - - // Remove old data + + // Remove old data this->buffer.clear(); - + // Copy data to internal buffer. - for( std::size_t ix = 0; ix < lbufferSize; ++ix ) - { - this->buffer.push_back(lbuffer[ix]); - } - + this->buffer.insert( this->buffer.end(), lbuffer, lbuffer + lbufferSize ); + // Begin at the Beginning. pos = this->buffer.begin(); - + // Notify any listening threds that there is now data available. notifyAll(); } @@ -66,15 +63,15 @@ //////////////////////////////////////////////////////////////////////////////// void BlockingByteArrayInputStream::close() throw (cms::CMSException){ - + synchronized( this ){ - + // Indicate that we're shutting down. closing = true; - + // Clear out the buffer. buffer.clear(); - + // Notify that this stream is shutting down. notifyAll(); } @@ -82,69 +79,69 @@ //////////////////////////////////////////////////////////////////////////////// unsigned char BlockingByteArrayInputStream::read() throw ( IOException ){ - + synchronized( this ){ - + while( !closing ){ - - if( pos != buffer.end() ){ + + if( pos != buffer.end() ){ return *(pos++); } - + // Wait for more data wait(); } - + throw IOException( __FILE__, __LINE__, "close occurred during read" ); } - + return 0; } //////////////////////////////////////////////////////////////////////////////// -std::size_t BlockingByteArrayInputStream::read( unsigned char* buffer, - std::size_t bufferSize ) +std::size_t BlockingByteArrayInputStream::read( unsigned char* buffer, + std::size_t bufferSize ) throw ( IOException ){ synchronized( this ){ - + std::size_t ix = 0; - + for( ; ix < bufferSize && !closing; ++ix, ++pos) { if(pos == this->buffer.end()) - { + { // Wait for more data to come in. wait(); } - + if( !closing ){ buffer[ix] = *(pos); } } - + if( closing ){ throw IOException( __FILE__, __LINE__, "close occurred during read" ); } - + return ix; } - + return 0; } //////////////////////////////////////////////////////////////////////////////// -std::size_t BlockingByteArrayInputStream::skip( std::size_t num ) +std::size_t BlockingByteArrayInputStream::skip( std::size_t num ) throw ( io::IOException, exceptions::UnsupportedOperationException ){ - + std::size_t ix = 0; - + synchronized( this ){ - + // Increment the pos until we'v skipped the desired num // or we've hit the end of the buffer. - for( ; ix < num && !closing && pos != buffer.end(); ++ix, ++pos) {} + for( ; ix < num && !closing && pos != buffer.end(); ++ix, ++pos) {} } - + return ix; } Modified: activemq/activemq-cpp/trunk/src/main/activemq/io/ByteArrayOutputStream.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/io/ByteArrayOutputStream.cpp?view=diff&rev=545967&r1=545966&r2=545967 ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/io/ByteArrayOutputStream.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/io/ByteArrayOutputStream.cpp Sun Jun 10 16:23:59 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "ByteArrayOutputStream.h" #include @@ -47,21 +47,17 @@ } //////////////////////////////////////////////////////////////////////////////// -void ByteArrayOutputStream::write( unsigned char c ) +void ByteArrayOutputStream::write( unsigned char c ) throw ( IOException ) { - activeBuffer->push_back( c ); + activeBuffer->push_back( c ); } -//////////////////////////////////////////////////////////////////////////////// -void ByteArrayOutputStream::write( const unsigned char* buffer, - std::size_t len ) +//////////////////////////////////////////////////////////////////////////////// +void ByteArrayOutputStream::write( const unsigned char* buffer, + std::size_t len ) throw ( IOException ) -{ - // Iterate until all the data is written. - for( std::size_t ix = 0; ix < len; ++ix) - { - activeBuffer->push_back( buffer[ix] ); - } +{ + activeBuffer->insert( activeBuffer->end(), buffer, buffer + len ); }