@@ -244,17 +244,17 @@ void await_worker_queue::resumePending()
244
244
// Default to immediate synchronous execution.
245
245
await_async::await_async ()
246
246
: _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>())) }
248
248
{
249
249
}
250
250
251
251
// Implicitly convert a std::launch parameter used with std::async to an awaitable.
252
252
await_async::await_async (std::launch launch)
253
253
: _pimpl { ((launch & std::launch::async) == std::launch::async)
254
254
? 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>()))
256
256
: 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>())) }
258
258
{
259
259
}
260
260
@@ -896,13 +896,17 @@ class SelectionVisitor
896
896
const TypeNames& _typeNames;
897
897
const ResolverMap& _resolvers;
898
898
899
+ static const Directives s_emptyFragmentDefinitionDirectives;
900
+
899
901
std::shared_ptr<FragmentDefinitionDirectiveStack> _fragmentDefinitionDirectives;
900
902
std::shared_ptr<FragmentSpreadDirectiveStack> _fragmentSpreadDirectives;
901
903
std::shared_ptr<FragmentSpreadDirectiveStack> _inlineFragmentDirectives;
902
904
internal::string_view_set _names;
903
905
std::vector<VisitorValue> _values;
904
906
};
905
907
908
+ const Directives SelectionVisitor::s_emptyFragmentDefinitionDirectives {};
909
+
906
910
SelectionVisitor::SelectionVisitor (const SelectionSetParams& selectionSetParams,
907
911
const FragmentMap& fragments, const response::Value& variables, const TypeNames& typeNames,
908
912
const ResolverMap& resolvers, std::size_t count)
@@ -917,19 +921,17 @@ SelectionVisitor::SelectionVisitor(const SelectionSetParams& selectionSetParams,
917
921
, _variables(variables)
918
922
, _typeNames(typeNames)
919
923
, _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 }) }
923
931
{
924
- static const Directives s_emptyFragmentDefinitionDirectives;
925
-
926
932
// Traversing a SelectionSet from an Object type field should start tracking new fragment
927
933
// directives. The outer fragment directives are still there in the FragmentSpreadDirectiveStack
928
934
// 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
-
933
935
_names.reserve (count);
934
936
_values.reserve (count);
935
937
}
@@ -1126,8 +1128,12 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)
1126
1128
return ;
1127
1129
}
1128
1130
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 });
1131
1137
1132
1138
const std::size_t count = itr->second .getSelection ().children .size ();
1133
1139
@@ -1142,8 +1148,8 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)
1142
1148
visit (*selection);
1143
1149
}
1144
1150
1145
- _fragmentSpreadDirectives-> pop_front () ;
1146
- _fragmentDefinitionDirectives-> pop_front () ;
1151
+ _fragmentSpreadDirectives = _fragmentSpreadDirectives-> outer ;
1152
+ _fragmentDefinitionDirectives = _fragmentDefinitionDirectives-> outer ;
1147
1153
}
1148
1154
1149
1155
void SelectionVisitor::visitInlineFragment (const peg::ast_node& inlineFragment)
@@ -1172,7 +1178,9 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment)
1172
1178
{
1173
1179
peg::on_first_child<peg::selection_set>(inlineFragment,
1174
1180
[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 });
1176
1184
1177
1185
const std::size_t count = child.children .size ();
1178
1186
@@ -1187,7 +1195,7 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment)
1187
1195
visit (*selection);
1188
1196
}
1189
1197
1190
- _inlineFragmentDirectives-> pop_front () ;
1198
+ _inlineFragmentDirectives = _inlineFragmentDirectives-> outer ;
1191
1199
});
1192
1200
}
1193
1201
}
@@ -1438,9 +1446,9 @@ void OperationDefinitionVisitor::visit(
1438
1446
_resolverContext,
1439
1447
_params->state ,
1440
1448
_params->directives ,
1441
- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1442
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1443
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1449
+ {} ,
1450
+ {} ,
1451
+ {} ,
1444
1452
std::nullopt,
1445
1453
_launch,
1446
1454
};
@@ -1855,9 +1863,9 @@ AwaitableSubscribe Request::subscribe(RequestSubscribeParams params)
1855
1863
ResolverContext::NotifySubscribe,
1856
1864
registration->data ->state ,
1857
1865
registration->data ->directives ,
1858
- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1859
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1860
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1866
+ {} ,
1867
+ {} ,
1868
+ {} ,
1861
1869
{},
1862
1870
launch,
1863
1871
};
@@ -1917,9 +1925,9 @@ AwaitableUnsubscribe Request::unsubscribe(RequestUnsubscribeParams params)
1917
1925
ResolverContext::NotifyUnsubscribe,
1918
1926
registration->data ->state ,
1919
1927
registration->data ->directives ,
1920
- std::make_shared<FragmentDefinitionDirectiveStack>() ,
1921
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1922
- std::make_shared<FragmentSpreadDirectiveStack>() ,
1928
+ {} ,
1929
+ {} ,
1930
+ {} ,
1923
1931
{},
1924
1932
params.launch ,
1925
1933
};
@@ -1980,9 +1988,9 @@ AwaitableDeliver Request::deliver(RequestDeliverParams params) const
1980
1988
ResolverContext::Subscription,
1981
1989
registration->data ->state ,
1982
1990
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> {} ,
1986
1994
std::nullopt,
1987
1995
params.launch ,
1988
1996
};
0 commit comments