Commit 217de3c3 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1355 Speed-up EnsightOutput tremendously by guessing where to look for the...

#1355 Speed-up EnsightOutput tremendously by guessing where to look for the sought interface. I have actually just implemented something I hinted in a comment long ago...
parent b8736302
......@@ -149,18 +149,35 @@ namespace MoReFEM
const Data::Interface& InterfaceFile::GetInterface(InterfaceNS::Nature interface_nature,
unsigned int interface_index) const
{
decltype(auto) interface_list = GetInterfaceList(interface_nature);
// \todo This could be sped up as interfaces are actually sort: we can have a pretty good idea of their
// position (so looking at [begin + interface_index - 2, begin + interface_index + 2] would be a pretty
// good guess...
const auto it_interface = std::find_if(interface_list.cbegin(),
interface_list.cend(),
[interface_index](const auto& interface_ptr)
auto lambda = [interface_index](const auto& interface_ptr)
{
assert(!(!interface_ptr));
return interface_index == interface_ptr->GetIndex();
});
};
auto guess_min = interface_list.cbegin() + interface_index - 3;
if (guess_min < interface_list.cbegin())
guess_min = interface_list.cbegin();
auto guess_max = guess_min + 6;
if (guess_max > interface_list.cend())
guess_max = interface_list.cend();
auto it_interface = std::find_if(guess_min,
guess_max,
lambda);
if (it_interface == guess_max)
{
it_interface = std::find_if(interface_list.cbegin(),
interface_list.cend(),
lambda);
}
assert(it_interface != interface_list.cend());
return *(*it_interface);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment