File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,15 @@ service::FieldResult<std::shared_ptr<service::Object>> Query::getHero(
1818 service::FieldParams&&, std::optional<Episode>&& episodeArg) const
1919{
2020 std::shared_ptr<service::Object> result;
21+ const auto episode = episodeArg ? *episodeArg : Episode::NEW_HOPE;
2122
22- if (episodeArg )
23+ if (const auto itr = heroes_. find (episode); itr != heroes_. end () )
2324 {
24- if (const auto itr = heroes_.find (*episodeArg); itr != heroes_.end ())
25- {
26- result = std::visit (
27- [](const auto & hero) noexcept {
28- return std::static_pointer_cast<service::Object>(hero);
29- },
30- itr->second );
31- }
25+ result = std::visit (
26+ [](const auto & hero) noexcept {
27+ return std::static_pointer_cast<service::Object>(hero);
28+ },
29+ itr->second );
3230 }
3331
3432 return { result };
You can’t perform that action at this time.
0 commit comments