Move LoadLeafFromDisk to return by value

This commit is contained in:
Patrick Niklaus 2016-05-01 01:14:26 +02:00
parent 63754df4d4
commit b11b471aa4
No known key found for this signature in database
GPG Key ID: E426891B5F978B1B

View File

@ -348,8 +348,7 @@ class StaticRTree
if (current_tree_node.child_is_on_disk) if (current_tree_node.child_is_on_disk)
{ {
LeafNode current_leaf_node; LeafNode current_leaf_node = LoadLeafFromDisk(current_tree_node.children[0]);
LoadLeafFromDisk(current_tree_node.children[0], current_leaf_node);
for (const auto i : irange(0u, current_leaf_node.object_count)) for (const auto i : irange(0u, current_leaf_node.object_count))
{ {
@ -488,8 +487,7 @@ class StaticRTree
return; return;
} }
LeafNode current_leaf_node; LeafNode current_leaf_node = LoadLeafFromDisk(leaf_id);
LoadLeafFromDisk(leaf_id, current_leaf_node);
// current object represents a block on disk // current object represents a block on disk
for (const auto i : irange(0u, current_leaf_node.object_count)) for (const auto i : irange(0u, current_leaf_node.object_count))
@ -529,8 +527,9 @@ class StaticRTree
} }
} }
inline void LoadLeafFromDisk(const std::uint32_t leaf_id, LeafNode &result_node) inline LeafNode LoadLeafFromDisk(const std::uint32_t leaf_id)
{ {
LeafNode result_node;
if (!leaves_stream.is_open()) if (!leaves_stream.is_open())
{ {
leaves_stream.open(m_leaf_node_filename, std::ios::in | std::ios::binary); leaves_stream.open(m_leaf_node_filename, std::ios::in | std::ios::binary);
@ -544,6 +543,7 @@ class StaticRTree
BOOST_ASSERT_MSG(leaves_stream.good(), "Seeking to position in leaf file failed."); BOOST_ASSERT_MSG(leaves_stream.good(), "Seeking to position in leaf file failed.");
leaves_stream.read((char *)&result_node, sizeof(LeafNode)); leaves_stream.read((char *)&result_node, sizeof(LeafNode));
BOOST_ASSERT_MSG(leaves_stream.good(), "Reading from leaf file failed."); BOOST_ASSERT_MSG(leaves_stream.good(), "Reading from leaf file failed.");
return result_node;
} }
template <typename CoordinateT> template <typename CoordinateT>