Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions libs/server-sdk/src/evaluation/detail/evaluation_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace launchdarkly::server_side::evaluation::detail {

Guard::Guard(std::unordered_set<std::string>& set, std::string const& key)
: set_(set), key_(key) {
Guard::Guard(std::unordered_set<std::string>& set, std::string key)
: set_(set), key_(std::move(key)) {
set_.insert(key_);
}

Expand All @@ -12,19 +12,19 @@ Guard::~Guard() {
}

std::optional<Guard> EvaluationStack::NoticePrerequisite(
std::string const& prerequisite_key) {
std::string prerequisite_key) {
if (prerequisites_seen_.count(prerequisite_key) != 0) {
return std::nullopt;
}
return std::make_optional<Guard>(prerequisites_seen_, prerequisite_key);
return std::make_optional<Guard>(prerequisites_seen_,
std::move(prerequisite_key));
}

std::optional<Guard> EvaluationStack::NoticeSegment(
std::string const& segment_key) {
std::optional<Guard> EvaluationStack::NoticeSegment(std::string segment_key) {
if (segments_seen_.count(segment_key) != 0) {
return std::nullopt;
}
return std::make_optional<Guard>(segments_seen_, segment_key);
return std::make_optional<Guard>(segments_seen_, std::move(segment_key));
}

} // namespace launchdarkly::server_side::evaluation::detail
9 changes: 4 additions & 5 deletions libs/server-sdk/src/evaluation/detail/evaluation_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace launchdarkly::server_side::evaluation::detail {
* Upon destruction, the key is forgotten.
*/
struct Guard {
Guard(std::unordered_set<std::string>& set, std::string const& key);
Guard(std::unordered_set<std::string>& set, std::string key);
~Guard();

Guard(Guard const&) = delete;
Expand All @@ -22,7 +22,7 @@ struct Guard {

private:
std::unordered_set<std::string>& set_;
std::string const& key_;
std::string const key_;
};

/**
Expand All @@ -41,7 +41,7 @@ class EvaluationStack {
* @return Guard object if not seen before, otherwise std::nullopt.
*/
[[nodiscard]] std::optional<Guard> NoticePrerequisite(
std::string const& prerequisite_key);
std::string prerequisite_key);

/**
* If the given segment key has not been seen, marks it as seen
Expand All @@ -50,8 +50,7 @@ class EvaluationStack {
* @param prerequisite_key Key of the segment.
* @return Guard object if not seen before, otherwise std::nullopt.
*/
[[nodiscard]] std::optional<Guard> NoticeSegment(
std::string const& segment_key);
[[nodiscard]] std::optional<Guard> NoticeSegment(std::string segment_key);

private:
std::unordered_set<std::string> prerequisites_seen_;
Expand Down
1 change: 1 addition & 0 deletions libs/server-sdk/src/evaluation/evaluation_error.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <optional>
#include <ostream>

namespace launchdarkly::server_side::evaluation {
Expand Down