Skip to content

Commit 6f52c1e

Browse files
[OpenACC] Avoid repeated hash lookups (NFC) (#108795)
1 parent 9159179 commit 6f52c1e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,9 +1790,8 @@ bool hasDuplicateDeviceTypes(
17901790
return false;
17911791
for (auto attr : *segments) {
17921792
auto deviceTypeAttr = mlir::dyn_cast<mlir::acc::DeviceTypeAttr>(attr);
1793-
if (deviceTypes.contains(deviceTypeAttr.getValue()))
1793+
if (!deviceTypes.insert(deviceTypeAttr.getValue()).second)
17941794
return true;
1795-
deviceTypes.insert(deviceTypeAttr.getValue());
17961795
}
17971796
return false;
17981797
}
@@ -1807,9 +1806,8 @@ LogicalResult checkDeviceTypes(mlir::ArrayAttr deviceTypes) {
18071806
mlir::dyn_cast_or_null<mlir::acc::DeviceTypeAttr>(attr);
18081807
if (!deviceTypeAttr)
18091808
return failure();
1810-
if (crtDeviceTypes.contains(deviceTypeAttr.getValue()))
1809+
if (!crtDeviceTypes.insert(deviceTypeAttr.getValue()).second)
18111810
return failure();
1812-
crtDeviceTypes.insert(deviceTypeAttr.getValue());
18131811
}
18141812
return success();
18151813
}

0 commit comments

Comments
 (0)