mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Apply Clang-Tidy readability-container-size-empty (#93236)
Not only is this change usually shorter and more readable, it also can yield better performance. size() is not always a constant time operation (such as on LinkedLists), but empty() always is. Pull Request resolved: https://github.com/pytorch/pytorch/pull/93236 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
239afa0e43
commit
0247ed27cc
@ -503,7 +503,7 @@ RangeValue::RangeValue(
|
||||
}
|
||||
|
||||
Graph& g = *m.graph();
|
||||
if (inputs.size() == 0) {
|
||||
if (inputs.empty()) {
|
||||
throw ErrorReport(loc) << "range expected at least 1 arguments, got 0";
|
||||
} else if (inputs.size() == 1) {
|
||||
end_ = inputs[0];
|
||||
@ -613,7 +613,7 @@ void IterableTree::addChild(
|
||||
GraphFunction& m,
|
||||
const SugaredValuePtr& iter_value) {
|
||||
c10::optional<int64_t> child_len = iter_value->staticLen();
|
||||
if (children_.size() == 0) {
|
||||
if (children_.empty()) {
|
||||
unroll_length_ = child_len;
|
||||
} else {
|
||||
if ((unroll_length_ && !child_len) || (child_len && !unroll_length_)) {
|
||||
@ -637,7 +637,7 @@ std::shared_ptr<SugaredValue> MagicMethod::call(
|
||||
at::ArrayRef<NamedValue> args,
|
||||
at::ArrayRef<NamedValue> kwargs,
|
||||
size_t n_binders) {
|
||||
if (args.size() > 0) {
|
||||
if (!args.empty()) {
|
||||
Value* self = args[0].value(*m.graph());
|
||||
if (auto class_ptr = self->type()->cast<ClassType>()) {
|
||||
return SimpleValue(self)
|
||||
|
Reference in New Issue
Block a user