1010#include < type_traits>
1111#include < set>
1212#include < boost/icl/interval_map.hpp>
13+ #include < boost/pool/pool_alloc.hpp>
1314
1415#include " rect.h"
1516
@@ -73,10 +74,12 @@ operator!=(const Event<T> &lhs, const Event<T> &rhs) noexcept {
7374 return !(lhs == rhs);
7475}
7576
77+ template <typename T>
78+ using interval_allocator = boost::fast_pool_allocator<T>;
79+
7680template <
7781 typename Iterator,
78- typename OutIterator,
79- template <typename T> typename Allocator = std::allocator
82+ typename OutIterator
8083>
8184OutIterator split_rectangles (Iterator begin, Iterator end, OutIterator result) {
8285 using rect_t = std::remove_cv_t <std::remove_reference_t <decltype (*begin)>>;
@@ -85,19 +88,16 @@ OutIterator split_rectangles(Iterator begin, Iterator end, OutIterator result) {
8588
8689 // queue of events
8790 std::multiset<
88- event_t
91+ event_t ,
92+ std::less<event_t >,
93+ boost::fast_pool_allocator<event_t >
8994 > events;
9095
9196 // control the events of rects that are no longer valid
9297 // this is necessary because a rect becomes invalid (because
9398 // we splitted it) in an enter event, we should mark the leave
9499 // event of this specific rectangle as invalid as well
95- std::unordered_set<
96- std::uint64_t ,
97- std::hash<std::uint64_t >,
98- std::equal_to<std::uint64_t >,
99- Allocator<std::uint64_t >
100- > removed;
100+ std::unordered_set<std::uint64_t > removed;
101101
102102 std::uint64_t cur_id = 0 ;
103103 // create an enter and leave events for the rectangle
@@ -124,7 +124,7 @@ OutIterator split_rectangles(Iterator begin, Iterator end, OutIterator result) {
124124 ICL_SECTION_INSTANCE (boost::icl::inter_section, size_type),
125125 ICL_INTERVAL_INSTANCE (ICL_INTERVAL_DEFAULT, size_type,
126126 ICL_COMPARE_INSTANCE (ICL_COMPARE_DEFAULT, size_type)),
127- Allocator
127+ interval_allocator
128128 > intervals;
129129
130130 // the rects difference operations produces no more than 8 new rectangles
0 commit comments