[mlir] Use `interleave` in `printOperands` (NFC)
authorJeff Niu <jeff@modular.com>
Thu, 29 Sep 2022 20:45:44 +0000 (13:45 -0700)
committerJeff Niu <jeff@modular.com>
Thu, 29 Sep 2022 22:58:37 +0000 (15:58 -0700)
Instead of reimplementing it.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134904

mlir/include/mlir/IR/OpImplementation.h

index fcfd2f5..78843ac 100644 (file)
@@ -356,13 +356,8 @@ public:
   /// Print a comma separated list of operands.
   template <typename IteratorType>
   void printOperands(IteratorType it, IteratorType end) {
-    if (it == end)
-      return;
-    printOperand(*it);
-    for (++it; it != end; ++it) {
-      getStream() << ", ";
-      printOperand(*it);
-    }
+    llvm::interleaveComma(llvm::make_range(it, end), getStream(),
+                          [this](Value value) { printOperand(value); });
   }
 
   /// Print the given successor.