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

Commit b278e013 authored by Yifan Hong's avatar Yifan Hong
Browse files

liblp: change some functions to use string_view

Converting all of them to string_view requires some
non-trivial amount of refactoring (because there is not
an implicit conversion from string_view to string), and
hence may be done later if necessary.

Test: builds
Bug: 135752105
Change-Id: I936ae7117500fadc7b34a5b91b279bc863d9919d
parent 61bffa5f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -458,7 +458,7 @@ Partition* MetadataBuilder::FindPartition(const std::string& name) {
    return nullptr;
}

PartitionGroup* MetadataBuilder::FindGroup(const std::string& group_name) {
PartitionGroup* MetadataBuilder::FindGroup(std::string_view group_name) {
    for (const auto& group : groups_) {
        if (group->name() == group_name) {
            return group.get();
@@ -1083,7 +1083,7 @@ std::vector<Partition*> MetadataBuilder::ListPartitionsInGroup(const std::string
    return partitions;
}

bool MetadataBuilder::ChangePartitionGroup(Partition* partition, const std::string& group_name) {
bool MetadataBuilder::ChangePartitionGroup(Partition* partition, std::string_view group_name) {
    if (!FindGroup(group_name)) {
        LERROR << "Partition cannot change to unknown group: " << group_name;
        return false;
+3 −3
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ class Partition final {

  private:
    void ShrinkTo(uint64_t aligned_size);
    void set_group_name(const std::string& group_name) { group_name_ = group_name; }
    void set_group_name(std::string_view group_name) { group_name_ = group_name; }

    std::string name_;
    std::string group_name_;
@@ -227,7 +227,7 @@ class MetadataBuilder {
    Partition* FindPartition(const std::string& name);

    // Find a group by name. If no group is found, nullptr is returned.
    PartitionGroup* FindGroup(const std::string& name);
    PartitionGroup* FindGroup(std::string_view name);

    // Add a predetermined extent to a partition.
    bool AddLinearExtent(Partition* partition, const std::string& block_device,
@@ -252,7 +252,7 @@ class MetadataBuilder {
    // the metadata is exported, to avoid errors during potential group and
    // size shuffling operations. This will return false if the new group does
    // not exist.
    bool ChangePartitionGroup(Partition* partition, const std::string& group_name);
    bool ChangePartitionGroup(Partition* partition, std::string_view group_name);

    // Changes the size of a partition group. Size constraints will not be
    // checked until metadata is exported, to avoid errors during group