AVRO-556. Poor performance for Reader::readBytes improved. Contributed by Dave Wright.
git-svn-id: https://svn.apache.org/repos/asf/avro/branches/branch-1.3@951751 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 3e1d596..1f08ad2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -28,6 +28,10 @@
AVRO-504. ruby impl could stand better error messages on schema parsing (jmhodges)
+ AVRO-556. Poor performance for Reader::readBytes improved
+ (Dave Wright via sbanacho)
+
+
BUG FIXES
AVRO-461. Skipping primitives in the ruby side (jmhodges)
diff --git a/lang/c++/api/Reader.hh b/lang/c++/api/Reader.hh
index cdf14aa..be6c2d9 100644
--- a/lang/c++/api/Reader.hh
+++ b/lang/c++/api/Reader.hh
@@ -92,19 +92,12 @@
void readBytes(std::vector<uint8_t> &val) {
int64_t size = readSize();
-
- val.reserve(size);
- uint8_t bval;
- for(size_t bytes = 0; bytes < static_cast<size_t>(size); bytes++) {
- in_.readByte(bval);
- val.push_back(bval);
- }
+ val.resize(size);
+ in_.readBytes(&val[0], size);
}
void readFixed(uint8_t *val, size_t size) {
- for(size_t bytes = 0; bytes < size; bytes++) {
- in_.readByte(val[bytes]);
- }
+ in_.readBytes(val, size);
}
template <size_t N>