Skip to content
Snippets Groups Projects
Commit a7d8dd25 authored by Sean McBride's avatar Sean McBride
Browse files

Eliminate (semantically) a repeated search in RemoveViewProp

Replaced HasViewProp() call with IndexOfFirstOccurence(), the former is just a thin wrapper of the latter anyway.

This way we can call the other variant of RemoveItem(), the one that takes the index instead of the prop itself.

With the current implementation of RemoveItem, this doesn't help much, but eventually can, as now it doesn't have to search for the prop *again*.
parent 6a5b11dc
No related branches found
No related tags found
No related merge requests found
......@@ -150,11 +150,15 @@ void vtkViewport::AddViewProp(vtkProp* p)
//------------------------------------------------------------------------------
void vtkViewport::RemoveViewProp(vtkProp* p)
{
if (p && this->HasViewProp(p))
if (p)
{
p->ReleaseGraphicsResources(this->VTKWindow);
p->RemoveConsumer(this);
this->Props->RemoveItem(p);
int index = this->Props->IndexOfFirstOccurence(p);
if (index >= 0)
{
p->ReleaseGraphicsResources(this->VTKWindow);
p->RemoveConsumer(this);
this->Props->RemoveItem(index);
}
}
}
......
......@@ -44,7 +44,7 @@ public:
/**
* Add a prop to the list of props. Does nothing if the prop is
* already present. Prop is the superclass of all actors, volumes,
* nullptr or already present. Prop is the superclass of all actors, volumes,
* 2D actors, composite props etc.
*/
VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL)
......@@ -56,13 +56,13 @@ public:
vtkPropCollection* GetViewProps() { return this->Props; }
/**
* Query if a prop is in the list of props.
* Query if a prop is in the list of props. Returns false for nullptr.
*/
vtkTypeBool HasViewProp(vtkProp*);
/**
* Remove a prop from the list of props. Does nothing if the prop
* is not already present or if the parameter is NULL.
* is nullptr or not already present.
*/
VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL)
void RemoveViewProp(vtkProp*);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment