@@ -244,17 +244,17 @@ void await_worker_queue::resumePending()
244244// Default to immediate synchronous execution.
245245await_async::await_async ()
246246 : _pimpl { std::static_pointer_cast<const Concept>(
247- std::make_shared<Model<std::suspend_never>>(std::make_shared<std::suspend_never>())) }
247+ std::make_shared<Model<std::suspend_never>>(std::make_shared<std::suspend_never>())) }
248248{
249249}
250250
251251// Implicitly convert a std::launch parameter used with std::async to an awaitable.
252252await_async::await_async (std::launch launch)
253253 : _pimpl { ((launch & std::launch::async) == std::launch::async)
254254 ? std::static_pointer_cast<const Concept>(std::make_shared<Model<await_worker_thread>>(
255- std::make_shared<await_worker_thread>()))
255+ std::make_shared<await_worker_thread>()))
256256 : std::static_pointer_cast<const Concept>(std::make_shared<Model<std::suspend_never>>(
257- std::make_shared<std::suspend_never>())) }
257+ std::make_shared<std::suspend_never>())) }
258258{
259259}
260260
@@ -896,13 +896,17 @@ class SelectionVisitor
896896 const TypeNames& _typeNames;
897897 const ResolverMap& _resolvers;
898898
899+ static const Directives s_emptyFragmentDefinitionDirectives;
900+
899901 std::shared_ptr<FragmentDefinitionDirectiveStack> _fragmentDefinitionDirectives;
900902 std::shared_ptr<FragmentSpreadDirectiveStack> _fragmentSpreadDirectives;
901903 std::shared_ptr<FragmentSpreadDirectiveStack> _inlineFragmentDirectives;
902904 internal::string_view_set _names;
903905 std::vector<VisitorValue> _values;
904906};
905907
908+ const Directives SelectionVisitor::s_emptyFragmentDefinitionDirectives {};
909+
906910SelectionVisitor::SelectionVisitor (const SelectionSetParams& selectionSetParams,
907911 const FragmentMap& fragments, const response::Value& variables, const TypeNames& typeNames,
908912 const ResolverMap& resolvers, std::size_t count)
@@ -917,19 +921,17 @@ SelectionVisitor::SelectionVisitor(const SelectionSetParams& selectionSetParams,
917921 , _variables(variables)
918922 , _typeNames(typeNames)
919923 , _resolvers(resolvers)
920- , _fragmentDefinitionDirectives { selectionSetParams.fragmentDefinitionDirectives }
921- , _fragmentSpreadDirectives { selectionSetParams.fragmentSpreadDirectives }
922- , _inlineFragmentDirectives { selectionSetParams.inlineFragmentDirectives }
924+ , _fragmentDefinitionDirectives { std::make_shared<FragmentDefinitionDirectiveStack>(
925+ FragmentDefinitionDirectiveStack { std::cref (s_emptyFragmentDefinitionDirectives),
926+ selectionSetParams.fragmentDefinitionDirectives }) }
927+ , _fragmentSpreadDirectives { std::make_shared<FragmentSpreadDirectiveStack>(
928+ FragmentSpreadDirectiveStack { {}, selectionSetParams.fragmentSpreadDirectives }) }
929+ , _inlineFragmentDirectives { std::make_shared<FragmentSpreadDirectiveStack>(
930+ FragmentSpreadDirectiveStack { {}, selectionSetParams.inlineFragmentDirectives }) }
923931{
924- static const Directives s_emptyFragmentDefinitionDirectives;
925-
926932 // Traversing a SelectionSet from an Object type field should start tracking new fragment
927933 // directives. The outer fragment directives are still there in the FragmentSpreadDirectiveStack
928934 // if the field accessors want to inspect them.
929- _fragmentDefinitionDirectives->push_front (std::cref (s_emptyFragmentDefinitionDirectives));
930- _fragmentSpreadDirectives->push_front ({});
931- _inlineFragmentDirectives->push_front ({});
932-
933935 _names.reserve (count);
934936 _values.reserve (count);
935937}
@@ -1126,8 +1128,12 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)
11261128 return ;
11271129 }
11281130
1129- _fragmentDefinitionDirectives->push_front (itr->second .getDirectives ());
1130- _fragmentSpreadDirectives->push_front (directiveVisitor.getDirectives ());
1131+ _fragmentDefinitionDirectives = std::make_shared<FragmentDefinitionDirectiveStack>(
1132+ FragmentDefinitionDirectiveStack { itr->second .getDirectives (),
1133+ _fragmentDefinitionDirectives });
1134+ _fragmentSpreadDirectives = std::make_shared<FragmentSpreadDirectiveStack>(
1135+ FragmentSpreadDirectiveStack { directiveVisitor.getDirectives (),
1136+ _fragmentSpreadDirectives });
11311137
11321138 const std::size_t count = itr->second .getSelection ().children .size ();
11331139
@@ -1142,8 +1148,8 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)
11421148 visit (*selection);
11431149 }
11441150
1145- _fragmentSpreadDirectives-> pop_front () ;
1146- _fragmentDefinitionDirectives-> pop_front () ;
1151+ _fragmentSpreadDirectives = _fragmentSpreadDirectives-> outer ;
1152+ _fragmentDefinitionDirectives = _fragmentDefinitionDirectives-> outer ;
11471153}
11481154
11491155void SelectionVisitor::visitInlineFragment (const peg::ast_node& inlineFragment)
@@ -1172,7 +1178,9 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment)
11721178 {
11731179 peg::on_first_child<peg::selection_set>(inlineFragment,
11741180 [this , &directiveVisitor](const peg::ast_node& child) {
1175- _inlineFragmentDirectives->push_front (directiveVisitor.getDirectives ());
1181+ _inlineFragmentDirectives = std::make_shared<FragmentSpreadDirectiveStack>(
1182+ FragmentSpreadDirectiveStack { directiveVisitor.getDirectives (),
1183+ _inlineFragmentDirectives });
11761184
11771185 const std::size_t count = child.children .size ();
11781186
@@ -1187,7 +1195,7 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment)
11871195 visit (*selection);
11881196 }
11891197
1190- _inlineFragmentDirectives-> pop_front () ;
1198+ _inlineFragmentDirectives = _inlineFragmentDirectives-> outer ;
11911199 });
11921200 }
11931201}
@@ -1438,9 +1446,9 @@ void OperationDefinitionVisitor::visit(
14381446 _resolverContext,
14391447 _params->state ,
14401448 _params->directives ,
1441- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1442- std::make_shared<FragmentSpreadDirectiveStack>() ,
1443- std::make_shared<FragmentSpreadDirectiveStack>() ,
1449+ {} ,
1450+ {} ,
1451+ {} ,
14441452 std::nullopt ,
14451453 _launch,
14461454 };
@@ -1855,9 +1863,9 @@ AwaitableSubscribe Request::subscribe(RequestSubscribeParams params)
18551863 ResolverContext::NotifySubscribe,
18561864 registration->data ->state ,
18571865 registration->data ->directives ,
1858- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1859- std::make_shared<FragmentSpreadDirectiveStack>() ,
1860- std::make_shared<FragmentSpreadDirectiveStack>() ,
1866+ {} ,
1867+ {} ,
1868+ {} ,
18611869 {},
18621870 launch,
18631871 };
@@ -1917,9 +1925,9 @@ AwaitableUnsubscribe Request::unsubscribe(RequestUnsubscribeParams params)
19171925 ResolverContext::NotifyUnsubscribe,
19181926 registration->data ->state ,
19191927 registration->data ->directives ,
1920- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1921- std::make_shared<FragmentSpreadDirectiveStack>() ,
1922- std::make_shared<FragmentSpreadDirectiveStack>() ,
1928+ {} ,
1929+ {} ,
1930+ {} ,
19231931 {},
19241932 params.launch ,
19251933 };
@@ -1980,9 +1988,9 @@ AwaitableDeliver Request::deliver(RequestDeliverParams params) const
19801988 ResolverContext::Subscription,
19811989 registration->data ->state ,
19821990 registration->data ->directives ,
1983- std::make_shared <FragmentDefinitionDirectiveStack>() ,
1984- std::make_shared <FragmentSpreadDirectiveStack>() ,
1985- std::make_shared <FragmentSpreadDirectiveStack>() ,
1991+ std::shared_ptr <FragmentDefinitionDirectiveStack> {} ,
1992+ std::shared_ptr <FragmentSpreadDirectiveStack> {} ,
1993+ std::shared_ptr <FragmentSpreadDirectiveStack> {} ,
19861994 std::nullopt ,
19871995 params.launch ,
19881996 };
0 commit comments