Skip to content

Commit dda3b3d

Browse files
committed
Minor optimization.
1 parent 154ad75 commit dda3b3d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

draw.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace lib_interval_tree
1616
{
1717
namespace
1818
{
19-
using int_tree_for_draw = interval_tree <int, closed>;
19+
using int_tree_for_draw = interval_tree <interval<int, closed>>;
2020
using int_tree_iterator = int_tree_for_draw::iterator;
2121
using const_int_tree_iterator = int_tree_for_draw::const_iterator;
2222

interval_tree.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,10 @@ namespace lib_interval_tree
673673
/**
674674
* Inserts an interval into the tree.
675675
*/
676-
iterator insert(interval_type const& ival)
676+
template <typename IntervalType = interval_type>
677+
iterator insert(IntervalType&& ival)
677678
{
678-
node_type* z = new node_type(nullptr, ival);
679+
node_type* z = new node_type(nullptr, std::forward <IntervalType&&> (ival));
679680
node_type* y = nullptr;
680681
node_type* x = root_;
681682
while (x)
@@ -708,9 +709,10 @@ namespace lib_interval_tree
708709
* @param ival The interval
709710
* @param exclusive Exclude borders.
710711
*/
711-
iterator insert_overlap(interval_type const& ival, bool exclusive = false)
712+
template <typename IntervalType = interval_type>
713+
iterator insert_overlap(IntervalType&& ival, bool exclusive = false)
712714
{
713-
auto iter = overlap_find(ival, exclusive);
715+
auto iter = overlap_find(std::forward <IntervalType&&> (ival), exclusive);
714716
if (iter == end())
715717
return insert(ival);
716718
else

0 commit comments

Comments
 (0)