diff --git a/c++/src/TypeImpl.cc b/c++/src/TypeImpl.cc index 209ffcdfb9..d1d9c6203f 100644 --- a/c++/src/TypeImpl.cc +++ b/c++/src/TypeImpl.cc @@ -403,9 +403,6 @@ namespace orc { case proto::Type_Kind_STRUCT: { TypeImpl* result = new TypeImpl(STRUCT); std::unique_ptr return_value = std::unique_ptr(result); - uint64_t size = static_cast(type.subtypes_size()); - std::vector typeList(size); - std::vector fieldList(size); for(int i=0; i < type.subtypes_size(); ++i) { result->addStructField(type.fieldnames(i), convertType(footer.types(static_cast @@ -644,32 +641,31 @@ namespace orc { const std::string &input, size_t start, size_t end) { - std::string types = input.substr(start, end - start); std::vector > > res; - size_t pos = 0; + size_t pos = start; - while (pos < types.size()) { + while (pos < end) { size_t endPos = pos; - while (endPos < types.size() && (isalnum(types[endPos]) || types[endPos] == '_')) { + while (endPos < end && (isalnum(input[endPos]) || input[endPos] == '_')) { ++endPos; } std::string fieldName; - if (types[endPos] == ':') { - fieldName = types.substr(pos, endPos - pos); + if (input[endPos] == ':') { + fieldName = input.substr(pos, endPos - pos); pos = ++endPos; - while (endPos < types.size() && isalpha(types[endPos])) { + while (endPos < end && isalpha(input[endPos])) { ++endPos; } } size_t nextPos = endPos + 1; - if (types[endPos] == '<') { + if (input[endPos] == '<') { int count = 1; - while (nextPos < types.size()) { - if (types[nextPos] == '<') { + while (nextPos < end) { + if (input[nextPos] == '<') { ++count; - } else if (types[nextPos] == '>') { + } else if (input[nextPos] == '>') { --count; } if (count == 0) { @@ -677,24 +673,24 @@ namespace orc { } ++nextPos; } - if (nextPos == types.size()) { + if (nextPos == end) { throw std::logic_error("Invalid type string. Cannot find closing >"); } - } else if (types[endPos] == '(') { - while (nextPos < types.size() && types[nextPos] != ')') { + } else if (input[endPos] == '(') { + while (nextPos < end && input[nextPos] != ')') { ++nextPos; } - if (nextPos == types.size()) { + if (nextPos == end) { throw std::logic_error("Invalid type string. Cannot find closing )"); } - } else if (types[endPos] != ',' && types[endPos] != '\0') { + } else if (input[endPos] != ',' && endPos != end) { throw std::logic_error("Unrecognized character."); } - std::string category = types.substr(pos, endPos - pos); - res.push_back(std::make_pair(fieldName, parseCategory(category, types, endPos + 1, nextPos))); + std::string category = input.substr(pos, endPos - pos); + res.push_back(std::make_pair(fieldName, parseCategory(category, input, endPos + 1, nextPos))); - if (nextPos < types.size() && (types[nextPos] == ')' || types[nextPos] == '>')) { + if (nextPos < end && (input[nextPos] == ')' || input[nextPos] == '>')) { pos = nextPos + 2; } else { pos = nextPos;