Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01a7dcb2 authored by Yi-Yo Chiang's avatar Yi-Yo Chiang Committed by Yi-yo Chiang
Browse files

first_stage_init: Optimize redundant vector copy

```
std::vector<std::string> v2;
for (auto&& e : get_temporary_v1()) { v2.push_back(e); }
```
^^^ This is constructing v2 from a temporary object, which is an
unnecessary manual clone. We should just let copy-elision do its thing:

```
// Give compiler the chance to optimize this with copy-elision...
auto v2 = get_temporary_v1();
```

Also `lp_names` appends an extra ',' at its end. Just use
android::base::Join() here.

Bug: 235111004
Test: Presubmit GSI boot test
Change-Id: Ibe8ce7a29b8521e789aa0a99f7f6d31f3f9c70e9
parent e8e7b3bb
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -651,14 +651,9 @@ void FirstStageMount::UseDsuIfPresent() {
        return;
    }

    std::string lp_names = "";
    std::vector<std::string> dsu_partitions;
    for (auto&& name : images->GetAllBackingImages()) {
        dsu_partitions.push_back(name);
        lp_names += name + ",";
    }
    // Publish the logical partition names for TransformFstabForDsu
    WriteFile(gsi::kGsiLpNamesFile, lp_names);
    // Publish the logical partition names for TransformFstabForDsu() and ReadFstabFromFile().
    const auto dsu_partitions = images->GetAllBackingImages();
    WriteFile(gsi::kGsiLpNamesFile, android::base::Join(dsu_partitions, ","));
    TransformFstabForDsu(&fstab_, active_dsu, dsu_partitions);
}