Skip to content

Commit a443c84

Browse files
committed
use ternary
1 parent d30e6b4 commit a443c84

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mlir/lib/Dialect/EmitC/Transforms/AddReflectionMap.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,20 @@ class AddReflectionMapClass : public OpRewritePattern<emitc::ClassOp> {
9696
fieldNames.emplace_back(stringAttr.getValue().str(),
9797
fieldOp.getName().str());
9898

99-
} else {
99+
} else
100100
fieldOp.emitError()
101101
<< "FieldOp must have a dictionary attribute named '"
102102
<< attributeName << "'"
103103
<< "with an array containing a string attribute";
104-
}
104+
105105
});
106106

107107
std::string mapString;
108108
mapString += "{ ";
109109
for (size_t i = 0; i < fieldNames.size(); ++i) {
110-
mapString += llvm::formatv("{ \"{0}\", reinterpret_cast<char*>(&{1}) }",
111-
fieldNames[i].first, fieldNames[i].second);
112-
if (i < fieldNames.size() - 1)
113-
mapString += ", ";
110+
mapString += llvm::formatv(
111+
"{ \"{0}\", reinterpret_cast<char*>(&{1}) }{2}", fieldNames[i].first,
112+
fieldNames[i].second, (i < fieldNames.size() - 1) ? ", " : "");
114113
}
115114
mapString += " }";
116115

0 commit comments

Comments
 (0)