diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h b/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h index 128eacdbe6ab7a..494026d78af3fd 100644 --- a/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h @@ -298,13 +298,10 @@ void TransformDialect::addTypeIfNotRegistered() { template DataTy &TransformDialect::getOrCreateExtraData() { TypeID typeID = TypeID::get(); - auto it = extraData.find(typeID); - if (it != extraData.end()) - return static_cast(*it->getSecond()); - - auto emplaced = - extraData.try_emplace(typeID, std::make_unique(getContext())); - return static_cast(*emplaced.first->getSecond()); + auto [it, inserted] = extraData.try_emplace(typeID); + if (inserted) + it->getSecond() = std::make_unique(getContext()); + return static_cast(*it->getSecond()); } /// A wrapper for transform dialect extensions that forces them to be