Simplify dispatch
This commit is contained in:
parent
6d632f6aa4
commit
1bf4170d8f
@ -851,7 +851,6 @@ namespace chaiscript
|
|||||||
Boxed_Value dispatch(const Funcs &funcs,
|
Boxed_Value dispatch(const Funcs &funcs,
|
||||||
const std::vector<Boxed_Value> &plist, const Type_Conversions &t_conversions)
|
const std::vector<Boxed_Value> &plist, const Type_Conversions &t_conversions)
|
||||||
{
|
{
|
||||||
//std::cout << "starting dispatch: " << funcs.size() << '\n';
|
|
||||||
std::vector<std::pair<size_t, const Proxy_Function_Base *>> ordered_funcs;
|
std::vector<std::pair<size_t, const Proxy_Function_Base *>> ordered_funcs;
|
||||||
ordered_funcs.reserve(funcs.size());
|
ordered_funcs.reserve(funcs.size());
|
||||||
|
|
||||||
@ -872,22 +871,16 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ordered_funcs.emplace_back(numdiffs, func.get());
|
ordered_funcs.emplace_back(numdiffs, func.get());
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stable_sort(ordered_funcs.begin(), ordered_funcs.end(),
|
|
||||||
[](const std::pair<size_t, const Proxy_Function_Base *> &t_lhs, const std::pair<size_t, const Proxy_Function_Base *> &t_rhs)
|
for (size_t i = 0; i <= plist.size(); ++i)
|
||||||
{
|
{
|
||||||
return t_lhs.first < t_rhs.first;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const auto &func : ordered_funcs )
|
for (const auto &func : ordered_funcs )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (func.first == 0 || func.second->filter(plist, t_conversions))
|
if (func.first == i && func.second->filter(plist, t_conversions))
|
||||||
{
|
{
|
||||||
return (*(func.second))(plist, t_conversions);
|
return (*(func.second))(plist, t_conversions);
|
||||||
}
|
}
|
||||||
@ -900,6 +893,7 @@ namespace chaiscript
|
|||||||
//try again
|
//try again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return detail::dispatch_with_conversions(funcs.cbegin(), funcs.cend(), plist, t_conversions);
|
return detail::dispatch_with_conversions(funcs.cbegin(), funcs.cend(), plist, t_conversions);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user