refactor: event id from const char* to string_view#469
Open
olgavrou wants to merge 12 commits into
Open
Conversation
lokitoth
approved these changes
Mar 31, 2022
jackgerrits
reviewed
Mar 31, 2022
| void continuous_action_response::set_event_id(const char* event_id) { | ||
| _event_id = event_id; | ||
| void continuous_action_response::set_event_id(string_view event_id) { | ||
| _event_id = std::string(event_id); |
Member
There was a problem hiding this comment.
Suggested change
| _event_id = std::string(event_id); | |
| _event_id = std::string{event_id}; |
| void continuous_action_response::set_model_id(const char* model_id) { | ||
| _model_id = model_id; | ||
| void continuous_action_response::set_model_id(string_view model_id) { | ||
| _model_id = std::string(model_id); |
Member
There was a problem hiding this comment.
Suggested change
| _model_id = std::string(model_id); | |
| _model_id = std::string{model_id}; |
| void episode_history::update(const char* event_id, const char* previous_event_id, string_view context, const ranking_response& resp) { | ||
| _depths[event_id] = this->get_depth(previous_event_id) + 1; | ||
| void episode_history::update(string_view event_id, string_view previous_event_id, string_view context, const ranking_response& resp) { | ||
| _depths[std::string(event_id)] = this->get_depth(previous_event_id) + 1; |
Member
There was a problem hiding this comment.
This is not great... We get heterogeneous lookup in c++14 for map I believe. Doesn't help us here though
|
|
||
| std::string episode_history::get_context(const char* previous_event_id, string_view context) const { | ||
| std::string episode_history::get_context(string_view previous_event_id, string_view context) const { | ||
| return R"({"episode":{"depth":")" + std::to_string(this->get_depth(previous_event_id) + 1) + "\"}," + std::string(context.data() + 1); |
Member
There was a problem hiding this comment.
Not part of this PR, but this should probably at least use a string stream
jackgerrits
approved these changes
Apr 1, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.