Skip to content

Commit

Permalink
perf: Improve perf of IBA::channels in-place operation (#4088)
Browse files Browse the repository at this point in the history
For the in-place case (where src and dst refer to the same IB), we were
doing an unnecessary full-image copy.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz authored Dec 25, 2023
1 parent e6c85b5 commit 406704d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libOpenImageIO/imagebufalgo_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ ImageBufAlgo::channels(ImageBuf& dst, const ImageBuf& src, int nchannels,
{
// Handle in-place case
if (&dst == &src) {
ImageBuf tmp = src;
return channels(dst, tmp, nchannels, channelorder, channelvalues,
newchannelnames, shuffle_channel_names, nthreads);
ImageBuf tmp;
bool ok = channels(tmp, src, nchannels, channelorder, channelvalues,
newchannelnames, shuffle_channel_names, nthreads);
dst = std::move(tmp);
return ok;
}

pvt::LoggedTimer logtime("IBA::channels");
Expand Down

0 comments on commit 406704d

Please sign in to comment.