[Mlir-commits] [mlir] 404d0e9 - [mlir] Adjust code flagged by ClangTidyPerformance (NFC).
Adrian Kuegel
llvmlistbot at llvm.org
Mon Nov 25 00:17:33 PST 2024
Author: Adrian Kuegel
Date: 2024-11-25T08:17:09Z
New Revision: 404d0e9966a46c29e6539e20d9295adcbc8bf9bf
URL: https://github.com/llvm/llvm-project/commit/404d0e9966a46c29e6539e20d9295adcbc8bf9bf
DIFF: https://github.com/llvm/llvm-project/commit/404d0e9966a46c29e6539e20d9295adcbc8bf9bf.diff
LOG: [mlir] Adjust code flagged by ClangTidyPerformance (NFC).
We can allocate the size of the vector in advance.
Added:
Modified:
mlir/lib/Bindings/Python/IRAttributes.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 417c66b9165e3b..cc9532f4e33b2c 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -1102,11 +1102,11 @@ class PyDenseElementsAttribute
unpackedBooleans = unpackedBooleans[py::slice(0, numBooleans, 1)];
unpackedBooleans = equalFunc(unpackedBooleans, 1);
- std::vector<intptr_t> shape;
MlirType shapedType = mlirAttributeGetType(*this);
intptr_t rank = mlirShapedTypeGetRank(shapedType);
+ std::vector<intptr_t> shape(rank);
for (intptr_t i = 0; i < rank; ++i) {
- shape.push_back(mlirShapedTypeGetDimSize(shapedType, i));
+ shape[i] = mlirShapedTypeGetDimSize(shapedType, i);
}
unpackedBooleans = reshapeFunc(unpackedBooleans, shape);
More information about the Mlir-commits
mailing list