Skip to content

Deprecate ReadPortal().Get pattern.

Nick Thompson requested to merge (removed):deprecate_read_portal_get into master

This begins a process of graceful deprecation of all API calls which lend themselves to the ReadPortal().Get(idx) pattern. In addition I removed a few more instances from the unit tests so that my greps were more legible; the main diff is to CellSetExplicit.

More important is what I wasn't able to do, which is deprecate the instances of the antipattern in CellSetPermutation; the main problem being that the natural way to change it is to change the meaning of the call, which can't be done via deprecation warnings.

For example, what we have is

vtkm::UInt8 GetCellShape(vtkm::Id id) const override
{
  // Looping over GetCellShape is a performance bug.
  return this->FullCellSet.GetCellShape(this->ValidCellIds.ReadPortal().Get(id));
}

// usage:
for (vtkm::Id id = 0; id < imax; ++id) {
    auto shape = foo.GetCellShape(id);
}

But what we want the user to do is:

auto ValidCellIdsReadPortal() {
    return this->ValidCellIds.ReadPortal();
}

vtkm::UInt8 GetCellShape(vtkm::Id cellIdx) const override
{
  return this->FullCellSet.GetCellShape(cellIdx);
}

// usage:
auto portal = foo.ValidCellIdsReadPortal();
for (vtkm::Id id = 0; id < imax; ++id) {
    auto shape = foo.GetCellShape(portal.Get(id));
}

which is backwards incompatible behavior.

Merge request reports

Loading