activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r545888 - /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp
Date Sun, 10 Jun 2007 15:25:58 GMT
Author: tabish
Date: Sun Jun 10 08:25:58 2007
New Revision: 545888

URL: http://svn.apache.org/viewvc?view=rev&rev=545888
Log:
https://issues.apache.org/activemq/browse/AMQCPP-103

Building up the Decaf Library

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp?view=diff&rev=545888&r1=545887&r2=545888
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp Sun Jun
10 08:25:58 2007
@@ -60,13 +60,10 @@
     activeBuffer = &defaultBuffer;
 
     // Remove old data
-    defaultBuffer.clear();
+    defaultBuffer.resize( lbufferSize );
 
-    // Copy data to internal buffer.
-    for( std::size_t ix = 0; ix < lbufferSize; ++ix )
-    {
-        defaultBuffer.push_back(lbuffer[ix]);
-    }
+    // Copy to internal buffer
+    std::copy( lbuffer, lbuffer + lbufferSize, &defaultBuffer[0] );
 
     // Begin at the Beginning.
     reset();
@@ -97,16 +94,14 @@
                                    throw ( IOException ){
     std::size_t ix = 0;
 
-    for( ; ix < bufferSize; ++ix, ++pos)
-    {
-        if(pos == activeBuffer->end())
-        {
-            // We don't have enough data to fulfill the request.
-            throw IOException(
-                __FILE__, __LINE__,
-                "Reached the end of the buffer" );
-        }
+    if( (std::size_t)distance( pos, activeBuffer->end() ) < bufferSize ) {
+        // We don't have enough data to fulfill the request.
+        throw IOException(
+            __FILE__, __LINE__,
+            "Reached the end of the buffer" );
+    }
 
+    for( ; ix < bufferSize; ++ix, ++pos) {
         buffer[ix] = *(pos);
     }
 



Mime
View raw message