Prevent unnecessary copies of vectors using references.

This commit is contained in:
Markus Blatt 2018-08-01 15:22:07 +02:00
parent 458cd8768f
commit f850f04c93
2 changed files with 6 additions and 6 deletions

View File

@ -183,7 +183,7 @@ colorVerticesWelshPowell(const Graph& graph)
template<class Graph>
std::vector<std::size_t>
reorderVerticesPreserving(const std::vector<int>& colors, int noColors,
const std::vector<std::size_t> verticesPerColor,
const std::vector<std::size_t>& verticesPerColor,
const Graph& graph)
{
std::vector<std::size_t> colorIndex(noColors, 0);
@ -203,7 +203,7 @@ reorderVerticesPreserving(const std::vector<int>& colors, int noColors,
template<class Graph>
std::vector<std::size_t>
reorderVerticesSpheres(const std::vector<int>& colors, int noColors,
const std::vector<std::size_t> verticesPerColor,
const std::vector<std::size_t>& verticesPerColor,
const Graph& graph,
typename Graph::VertexDescriptor root)
{

View File

@ -168,14 +168,14 @@ namespace Opm
struct RealReorderer : public Reorderer
{
RealReorderer(std::vector<std::size_t> ordering)
: ordering_(ordering)
RealReorderer(const std::vector<std::size_t>& ordering)
: ordering_(&ordering)
{}
virtual std::size_t operator[](std::size_t i) const
{
return ordering_[i];
return (*ordering_)[i];
}
std::vector<std::size_t> ordering_;
const std::vector<std::size_t>* ordering_;
};
struct IdentityFunctor