Skip to content

Commit

Permalink
[BE]: Enable clang-tidy check for readability-string-compare (pytorch…
Browse files Browse the repository at this point in the history
…#115994)

Adds a clang-tidy check to ensure string compare is not used unnecessarily in a way that is less efficient and less readable if an equality overload exists.

Pull Request resolved: pytorch#115994
Approved by: https://github.com/albanD
  • Loading branch information
Skylion007 authored and pytorchmergebot committed Dec 18, 2023
1 parent d7caef7 commit 647f14e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ modernize-*,
-modernize-use-nodiscard,
performance-*,
readability-container-size-empty,
readability-string-compare,
'
HeaderFilterRegex: '^(aten/|c10/|torch/).*$'
AnalyzeTemporaryDtors: false
Expand Down
4 changes: 2 additions & 2 deletions torch/csrc/distributed/c10d/ProcessGroupWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ struct CollectiveFingerPrint {
// Check op type
auto other_op = opTypeToString(other.op_type_);
auto this_op = opTypeToString(op_type_);
if (other_op.compare(this_op) != 0) {
if (other_op != this_op) {
found_diff = true;
ss << c10::str(" Op type: ", this_op, "vs ", other_op);
}
Expand All @@ -258,7 +258,7 @@ struct CollectiveFingerPrint {
return;
}
for (size_t i = 0; i < other.size(); ++i) {
if (other[i].compare(curr[i]) != 0) {
if (other[i] != curr[i]) {
found_diff = true;
ss << c10::str(" Tensor ", arg, ": ", curr, "vs ", other);
return;
Expand Down

0 comments on commit 647f14e

Please sign in to comment.