Skip to content

Commit

Permalink
Return the layer list by ref-to-const
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 12, 2020
1 parent f37dc03 commit bc1727f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/ilayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Layered
/**
* Return the set of layers to which this object is assigned.
*/
virtual LayerList getLayers() const = 0;
virtual const LayerList& getLayers() const = 0;

/**
* greebo: This assigns the given node to the given set of layers. Any previous
Expand Down
8 changes: 4 additions & 4 deletions libs/scene/LayerValidityCheckWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class LayerValidityCheckWalker :
// Returns true if the node has been "fixed"
static bool ProcessNode(const INodePtr& node)
{
LayerList list = node->getLayers();
LayerList list = node->getLayers(); // create a copy of the list

bool fixed = false;

for (LayerList::iterator i = list.begin(); i != list.end(); ++i)
for (auto id : list)
{
if (!GlobalLayerSystem().layerExists(*i))
if (!GlobalLayerSystem().layerExists(id))
{
node->removeFromLayer(*i);
node->removeFromLayer(id);
fixed = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/scene/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void Node::removeFromLayer(int layerId)
}
}

LayerList Node::getLayers() const
const LayerList& Node::getLayers() const
{
return _layers;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/scene/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Node :
virtual void addToLayer(int layerId) override;
virtual void removeFromLayer(int layerId) override;
virtual void moveToLayer(int layerId) override;
virtual LayerList getLayers() const override;
virtual const LayerList& getLayers() const override;
virtual void assignToLayers(const LayerList& newLayers) override;

virtual void addChildNode(const INodePtr& node) override;
Expand Down
3 changes: 1 addition & 2 deletions radiant/layers/LayerSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ void LayerSystem::removeSelectionFromLayer(int layerID) {
bool LayerSystem::updateNodeVisibility(const scene::INodePtr& node)
{
// Get the list of layers the node is associated with
// greebo: FIXME: Check if returning the LayerList by value is taxing.
LayerList layers = node->getLayers();
const auto& layers = node->getLayers();

// We start with the assumption that a node is hidden
node->enable(Node::eLayered);
Expand Down
2 changes: 1 addition & 1 deletion radiant/layers/LayerUsageBreakdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace
{
void addNodeMapping(LayerUsageBreakdown& bd, const scene::INodePtr& node)
{
scene::LayerList layers = node->getLayers();
const auto& layers = node->getLayers();

for (int layerId : layers)
{
Expand Down
2 changes: 1 addition & 1 deletion radiant/layers/SetLayerSelectedWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SetLayerSelectedWalker :
return true;
}

LayerList layers = node->getLayers();
const auto& layers = node->getLayers();

if (layers.find(_layer) != layers.end())
{
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/format/portable/PortableMapWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void PortableMapWriter::endWritePatch(const IPatchNodePtr& patch, std::ostream&

void PortableMapWriter::appendLayerInformation(xml::Node& xmlNode, const scene::INodePtr& sceneNode)
{
auto layers = sceneNode->getLayers();
const auto& layers = sceneNode->getLayers();
auto layersTag = xmlNode.createChild(TAG_OBJECT_LAYERS);

// Write the list of node IDs
Expand Down

0 comments on commit bc1727f

Please sign in to comment.