Skip to content

Commit

Permalink
refactor(search_family): address comments 3
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Bagritsevich <[email protected]>
  • Loading branch information
BagritsevichStepan committed Nov 19, 2024
1 parent 97dde54 commit 8375d3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/core/string_or_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class StringOrView {
val_ = std::string{std::get<std::string_view>(val_)};
}

bool empty() const {
return visit([](const auto& s) { return s.empty(); }, val_);
}

private:
std::variant<std::string_view, std::string> val_;
};
Expand Down
6 changes: 3 additions & 3 deletions src/server/search/doc_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ class SearchField {

private:
bool HasNewAlias() const {
return new_alias_.has_value();
return !new_alias_.empty();
}

std::string_view NameView() const {
return name_.view();
}

std::string_view AliasView() const {
return new_alias_.value().view();
return new_alias_.view();
}

private:
StringOrView name_;
bool is_short_name_;
std::optional<StringOrView> new_alias_;
StringOrView new_alias_;
};

using SearchFieldsList = std::vector<SearchField>;
Expand Down

0 comments on commit 8375d3f

Please sign in to comment.