# HG changeset patch # User František Kučera # Date 1537046570 -7200 # Node ID fc0d05b722147236a9c36fa21d82db39717f606d # Parent 6f7acc3b274c35bf6fa9140092ef25459ef5b1f9 AttributeMetadata: use vector.reserve() instead of resize() and [i] and thus avoid unwanted AttributeMetadata() constructor call diff -r 6f7acc3b274c -r fc0d05b72214 include/relpipe/reader/handlers/AttributeMetadata.h --- a/include/relpipe/reader/handlers/AttributeMetadata.h Sat Sep 15 22:52:15 2018 +0200 +++ b/include/relpipe/reader/handlers/AttributeMetadata.h Sat Sep 15 23:22:50 2018 +0200 @@ -14,10 +14,6 @@ public: ~AttributeMetadata(); - AttributeMetadata() { - std::cout << "FIXME: why call AttributeMetadata() ?" << std::endl; - } - AttributeMetadata(AttributeMetadataPrivate* impl) : impl(impl) { } diff -r 6f7acc3b274c -r fc0d05b72214 src/StreamRelationalReader.h --- a/src/StreamRelationalReader.h Sat Sep 15 22:52:15 2018 +0200 +++ b/src/StreamRelationalReader.h Sat Sep 15 23:22:50 2018 +0200 @@ -142,24 +142,23 @@ // Read column count columnCount = integerReader.readValue(input); - columnTypes.resize(columnCount); - columnNames.resize(columnCount); - columns.resize(columnCount); + columnTypes.reserve(columnCount); + columnNames.reserve(columnCount); + columns.reserve(columnCount); // Read column names for (int i = 0; i < columnCount; i++) { - columnNames[i] = stringReader.readValue(input); + columnNames.push_back(stringReader.readValue(input)); } // Read column types for (int i = 0; i < columnCount; i++) { TypeId typeId = (TypeId) integerReader.readValue(input); // TODO: přetypování OK? string_t typeCode = toTypeCode(typeId); // validate typeId TODO: je potřeba? - columnTypes[i] = typeId; + columnTypes.push_back(typeId); // put together names, type ids and type codes: - handlers::AttributeMetadataPrivate* xxx = new handlers::AttributeMetadataPrivate({columnNames[i], columnTypes[i], typeCode}); - columns[i] = handlers::AttributeMetadata(xxx); + columns.push_back(handlers::AttributeMetadata(new handlers::AttributeMetadataPrivate({columnNames[i], columnTypes[i], typeCode}))); } for (StringHandler* handler : stringHandlers) handler->startRelation(tableName, columns);