std::list <std::tuple<u64, u32, u32> > m_protected_ranges;
It appears they are not sorted. If so, consider using a vector and remove elements using swap and pop trick. MUCH faster:
/** Used for efficient removal in std::vector and std::deque (like an std::list)
However it assumes the order of elements in container is not important or
something external to the container holds the index of an element in it
(but still should be kept deterministically across machines)
Basically it swaps the iterator with the last iterator, and pops back
Returns the next iterator
*/
template<typename T>
typename T::iterator efficientVectorRemove( T& container, typename T::iterator& iterator )
{
const size_t idx = iterator - container.begin();
*iterator = container.back();
container.pop_back();
return container.begin() + idx;
}
nextElement = efficientVectorRemove( container, elementToRemove );
//remember that container.end() has been updated now.