From 1cd47d7af20c1fd9985e7a48dadd797c400f315d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 27 Jun 2017 11:55:14 -0700 Subject: [PATCH] Reserve expected length of instructions vector --- source/validate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/validate.cpp b/source/validate.cpp index 03bc6d9..cf86478 100644 --- a/source/validate.cpp +++ b/source/validate.cpp @@ -317,6 +317,8 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( // NOTE: Copy each instruction for easier processing std::vector instructions; + // Expect average instruction length to be a bit over 2 words. + instructions.reserve(binary->wordCount / 2); uint64_t index = SPV_INDEX_INSTRUCTION; while (index < binary->wordCount) { uint16_t wordCount; -- 2.7.4