mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 19:32:11 +08:00
Use pass by reference for const auto in for loop. (#9811)
This commit is contained in:
@@ -305,7 +305,7 @@ const std::string ResourceSet::ToString() const {
|
||||
|
||||
const std::unordered_map<std::string, double> ResourceSet::GetResourceMap() const {
|
||||
std::unordered_map<std::string, double> result;
|
||||
for (const auto resource_pair : resource_capacity_) {
|
||||
for (const auto &resource_pair : resource_capacity_) {
|
||||
result[resource_pair.first] = resource_pair.second.ToDouble();
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -45,7 +45,7 @@ class ActorInfoAccessorTest : public AccessorTestBase<ActorID, ActorTableData> {
|
||||
}
|
||||
|
||||
void GenCheckpointData() {
|
||||
for (const auto item : id_to_data_) {
|
||||
for (const auto &item : id_to_data_) {
|
||||
const ActorID &id = item.first;
|
||||
ActorCheckpointList checkpoints;
|
||||
for (size_t i = 0; i < checkpoint_number_; ++i) {
|
||||
|
||||
@@ -3589,7 +3589,7 @@ void NodeManager::FlushObjectsToFree() {
|
||||
void NodeManager::HandleGetNodeStats(const rpc::GetNodeStatsRequest &node_stats_request,
|
||||
rpc::GetNodeStatsReply *reply,
|
||||
rpc::SendReplyCallback send_reply_callback) {
|
||||
for (const auto task : local_queues_.GetTasks(TaskState::INFEASIBLE)) {
|
||||
for (const auto &task : local_queues_.GetTasks(TaskState::INFEASIBLE)) {
|
||||
if (task.GetTaskSpecification().IsActorCreationTask()) {
|
||||
auto infeasible_task = reply->add_infeasible_tasks();
|
||||
infeasible_task->ParseFromString(task.GetTaskSpecification().Serialize());
|
||||
@@ -3597,7 +3597,7 @@ void NodeManager::HandleGetNodeStats(const rpc::GetNodeStatsRequest &node_stats_
|
||||
}
|
||||
// Report tasks that are not scheduled because
|
||||
// resources are occupied by other actors/tasks.
|
||||
for (const auto task : local_queues_.GetTasks(TaskState::READY)) {
|
||||
for (const auto &task : local_queues_.GetTasks(TaskState::READY)) {
|
||||
if (task.GetTaskSpecification().IsActorCreationTask()) {
|
||||
auto ready_task = reply->add_ready_tasks();
|
||||
ready_task->ParseFromString(task.GetTaskSpecification().Serialize());
|
||||
|
||||
@@ -329,7 +329,7 @@ TaskResourceInstances NodeResourceInstances::GetAvailableResourceInstances() {
|
||||
task_resources.predefined_resources[i] = this->predefined_resources[i].available;
|
||||
}
|
||||
|
||||
for (const auto it : this->custom_resources) {
|
||||
for (const auto &it : this->custom_resources) {
|
||||
task_resources.custom_resources.emplace(it.first, it.second.available);
|
||||
}
|
||||
|
||||
@@ -365,8 +365,8 @@ bool TaskResourceInstances::IsEmpty() const {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto custom_resource : custom_resources) {
|
||||
for (const auto custom_resource_instances : custom_resource.second) {
|
||||
for (const auto &custom_resource : custom_resources) {
|
||||
for (const auto &custom_resource_instances : custom_resource.second) {
|
||||
if (custom_resource_instances != 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ int64_t ClusterResourceScheduler::IsSchedulable(const TaskRequest &task_req,
|
||||
}
|
||||
|
||||
// Now check custom resources.
|
||||
for (const auto task_req_custom_resource : task_req.custom_resources) {
|
||||
for (const auto &task_req_custom_resource : task_req.custom_resources) {
|
||||
auto it = resources.custom_resources.find(task_req_custom_resource.id);
|
||||
|
||||
if (it == resources.custom_resources.end()) {
|
||||
@@ -1038,7 +1038,7 @@ void ClusterResourceScheduler::UpdateLocalAvailableResourcesFromResourceInstance
|
||||
auto it = local_resources_.custom_resources.find(custom_resource.first);
|
||||
if (it != local_resources_.custom_resources.end()) {
|
||||
custom_resource.second.available = 0;
|
||||
for (const auto available : it->second.available) {
|
||||
for (const auto &available : it->second.available) {
|
||||
custom_resource.second.available += available;
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ void ClusterResourceScheduler::FreeTaskResourceInstances(
|
||||
&local_resources_.predefined_resources[i]);
|
||||
}
|
||||
|
||||
for (const auto task_allocation_custom_resource : task_allocation->custom_resources) {
|
||||
for (const auto &task_allocation_custom_resource : task_allocation->custom_resources) {
|
||||
auto it =
|
||||
local_resources_.custom_resources.find(task_allocation_custom_resource.first);
|
||||
if (it != local_resources_.custom_resources.end()) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class MockExporter : public opencensus::stats::StatsExporter::Handler {
|
||||
|
||||
ASSERT_EQ("current_worker", descriptor.name());
|
||||
ASSERT_EQ(opencensus::stats::ViewData::Type::kDouble, view_data.type());
|
||||
for (const auto row : view_data.double_data()) {
|
||||
for (const auto &row : view_data.double_data()) {
|
||||
for (size_t i = 0; i < descriptor.columns().size(); ++i) {
|
||||
if (descriptor.columns()[i].name() == "WorkerPidKey") {
|
||||
ASSERT_EQ("1000", row.first[i]);
|
||||
|
||||
Reference in New Issue
Block a user