summaryrefslogtreecommitdiff
path: root/source/comp/markv_codec.cpp
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2017-06-27 16:28:22 -0700
committerDavid Neto <dneto@google.com>2017-07-04 12:02:26 -0400
commit78338d5ba91f58428400c6619c131acc95512ff0 (patch)
treecd68af9c02714db2e7c7e81f45ba6e9ecd5abf77 /source/comp/markv_codec.cpp
parente842c17eb5a25c2856781f71a2e1876c58279f9d (diff)
Convert pattern stack from deque to vector, and share it
Also move various vector::reserve calls to State ctor Negligible perf benefit, but more tidy.
Diffstat (limited to 'source/comp/markv_codec.cpp')
-rw-r--r--source/comp/markv_codec.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/comp/markv_codec.cpp b/source/comp/markv_codec.cpp
index f621d3b3..9a080ee2 100644
--- a/source/comp/markv_codec.cpp
+++ b/source/comp/markv_codec.cpp
@@ -1178,7 +1178,7 @@ spv_result_t MarkvDecoder::DecodeOperand(
}
// Prepare to accept operands to this operand, if needed.
- spvPrependOperandTypes(entry->operandTypes, expected_operands);
+ spvPushOperandTypes(entry->operandTypes, expected_operands);
break;
}
@@ -1221,7 +1221,7 @@ spv_result_t MarkvDecoder::DecodeOperand(
<< mask;
}
remaining_word ^= mask;
- spvPrependOperandTypes(entry->operandTypes, expected_operands);
+ spvPushOperandTypes(entry->operandTypes, expected_operands);
}
}
if (word == 0) {
@@ -1229,7 +1229,7 @@ spv_result_t MarkvDecoder::DecodeOperand(
spv_operand_desc entry;
if (SPV_SUCCESS == grammar_.lookupOperand(type, 0, &entry)) {
// Prepare for its operands, if any.
- spvPrependOperandTypes(entry->operandTypes, expected_operands);
+ spvPushOperandTypes(entry->operandTypes, expected_operands);
}
}
break;
@@ -1287,9 +1287,10 @@ spv_result_t MarkvDecoder::DecodeInstruction(spv_parsed_instruction_t* inst) {
return vstate_.diag(SPV_ERROR_INVALID_BINARY) << "Invalid opcode";
}
- spv_operand_pattern_t expected_operands(
- opcode_desc->operandTypes,
- opcode_desc->operandTypes + opcode_desc->numTypes);
+ spv_operand_pattern_t expected_operands;
+ expected_operands.reserve(opcode_desc->numTypes);
+ for (auto i = 0; i < opcode_desc->numTypes; i++)
+ expected_operands.push_back(opcode_desc->operandTypes[opcode_desc->numTypes - i - 1]);
if (!OpcodeHasFixedNumberOfOperands(opcode)) {
if (!reader_.ReadVariableWidthU16(&inst->num_operands,