Skip to content

Commit 0bc68ca

Browse files
committed
[TableGen] Optimize SizeToOperandName iteration. NFC
1 parent 126f037 commit 0bc68ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/utils/TableGen/InstrInfoEmitter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Types.h"
2323
#include "llvm/ADT/ArrayRef.h"
2424
#include "llvm/ADT/STLExtras.h"
25+
#include "llvm/ADT/SmallVector.h"
2526
#include "llvm/ADT/StringExtras.h"
2627
#include "llvm/Support/Casting.h"
2728
#include "llvm/Support/raw_ostream.h"
@@ -474,15 +475,15 @@ void InstrInfoEmitter::emitOperandTypeMappings(
474475
OS << "LLVM_READONLY\n";
475476
OS << "static int getMemOperandSize(int OpType) {\n";
476477
OS << " switch (OpType) {\n";
477-
std::map<int, std::vector<StringRef>> SizeToOperandName;
478+
std::map<int, SmallVector<StringRef, 0>> SizeToOperandName;
478479
for (const Record *Op : Operands) {
479480
if (!Op->isSubClassOf("X86MemOperand"))
480481
continue;
481482
if (int Size = Op->getValueAsInt("Size"))
482483
SizeToOperandName[Size].push_back(Op->getName());
483484
}
484485
OS << " default: return 0;\n";
485-
for (auto KV : SizeToOperandName) {
486+
for (const auto &KV : SizeToOperandName) {
486487
for (const StringRef &OperandName : KV.second)
487488
OS << " case OpTypes::" << OperandName << ":\n";
488489
OS << " return " << KV.first << ";\n\n";

0 commit comments

Comments
 (0)