You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by sb...@apache.org on 2010/06/05 07:31:10 UTC

svn commit: r951653 - in /avro/trunk: CHANGES.txt lang/c++/api/Reader.hh

Author: sbanacho
Date: Sat Jun  5 05:31:10 2010
New Revision: 951653

URL: http://svn.apache.org/viewvc?rev=951653&view=rev
Log:

AVRO-556. Poor performance for Reader::readBytes can be easily improved.
Contributed by Dave Wright


Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c++/api/Reader.hh

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=951653&r1=951652&r2=951653&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Sat Jun  5 05:31:10 2010
@@ -47,6 +47,9 @@ Avro 1.4.0 (unreleased)
     AVRO-559. Handle read_union error where the list index of the union branch 
     to follow exceeds the size of the union schema (hammer)
 
+    AVRO-556. Poor performance for Reader::readBytes can be easily improved
+    (Dave Wright via sbanacho)
+
   BUG FIXES
     AVRO-461. Skipping primitives in the ruby side (jmhodges)
 

Modified: avro/trunk/lang/c++/api/Reader.hh
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/api/Reader.hh?rev=951653&r1=951652&r2=951653&view=diff
==============================================================================
--- avro/trunk/lang/c++/api/Reader.hh (original)
+++ avro/trunk/lang/c++/api/Reader.hh Sat Jun  5 05:31:10 2010
@@ -56,7 +56,7 @@ class ReaderImpl : private boost::noncop
 
     void readValue(bool &val) {
         validator_.checkTypeExpected(AVRO_BOOL);
-        uint8_t ival;
+        uint8_t ival = 0;
         reader_.read(ival);
         val = (ival != 0);
     }
@@ -102,13 +102,8 @@ class ReaderImpl : private boost::noncop
     void readBytes(std::vector<uint8_t> &val) {
         validator_.checkTypeExpected(AVRO_BYTES);
         int64_t size = readSize();
-        
-        val.reserve(size);
-        uint8_t bval;
-        for(size_t bytes = 0; bytes < static_cast<size_t>(size); bytes++) {
-            reader_.read(bval);
-            val.push_back(bval);
-        }
+        val.resize(size);
+        reader_.read(reinterpret_cast<char *>(&val[0]), size);
     }
 
     void readFixed(uint8_t *val, size_t size) {