Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
db9a45a
Op.cpp: remove dependency on pystring
KevinJW Jan 12, 2026
3108f0a
Op.h: Remove unused sstream include
KevinJW Jan 12, 2026
ff859cd
Add additional output during optimisation to show the results of ach …
KevinJW Jan 12, 2026
a818bb7
Add <cstring> for memcpy to test code
KevinJW Jan 12, 2026
40944b6
Improve uniformity of optimisation passes
KevinJW Jun 23, 2026
16d396e
refactor: Remove redundant comment and ensure we always use the passe…
KevinJW Jun 24, 2026
95b2c19
refactor: Try replace manual iterator handling with std algorithms
KevinJW Jun 25, 2026
b9595b2
style: fix some typos
KevinJW Jun 25, 2026
8ca63cc
refactor: Avoid shuffling the Ops vector entries unnecessarily
KevinJW Jun 26, 2026
37d863b
refactor: Avoid constructing temporary strings and use string_view to…
KevinJW Jun 26, 2026
a29f518
refactor: Simplify OptimizeSeparablePrefix to avoid duplicated loops
KevinJW Jun 26, 2026
6e8ccca
refactor: Reuse PerformOptimisation() to call RemoveDynamicProperties…
KevinJW Jun 26, 2026
50b9652
refactor: avoid casting to int now we no longer manually managing ind…
KevinJW Jun 26, 2026
e494d58
refactor: Avoid scanning whole OpVec when looking for expensive ops
KevinJW Jun 26, 2026
93f8934
refactor: Avoiod reallocating temporary during ReplaceInverseLuts
KevinJW Jun 26, 2026
db4bfbe
refactor: markup simple uses of using const pointers to gain access t…
KevinJW Jun 26, 2026
695309c
refactor: remove some unnecassary variables replacing with std::as_co…
KevinJW Jun 26, 2026
2d42328
refactor: Add some of the missing functions to make OpVec more std co…
KevinJW Jun 26, 2026
9113131
refactor: Move implementation into header for 'simple' functions that…
KevinJW Jun 27, 2026
5ad9b0b
refactor: Try avoid copying temporary shared_ptr using emplace_back
KevinJW Jun 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/OpenColorIO/NamedTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void NamedTransformImpl::addAlias(const char * alias) noexcept
{
if (!StringUtils::Contain(m_aliases, alias))
{
m_aliases.push_back(alias);
m_aliases.emplace_back(alias);
}
}
}
Expand Down Expand Up @@ -279,7 +279,7 @@ std::ostream & operator<< (std::ostream & os, const NamedTransform & t)
StringUtils::StringVec categories;
for (int i = 0; i < t.getNumCategories(); ++i)
{
categories.push_back(t.getCategory(i));
categories.emplace_back(t.getCategory(i));
}
os << ", categories=[" << StringUtils::Join(categories, ',') << "]";
}
Expand Down
185 changes: 15 additions & 170 deletions src/OpenColorIO/Op.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.

#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>

#include <pystring.h>

#include <OpenColorIO/OpenColorIO.h>

#include "Logging.h"
Expand All @@ -26,41 +25,11 @@

namespace OCIO_NAMESPACE
{
bool OpCPU::isDynamic() const
{
return false;
}

bool OpCPU::hasDynamicProperty(DynamicPropertyType /* type */) const
{
return false;
}

DynamicPropertyRcPtr OpCPU::getDynamicProperty(DynamicPropertyType /* type */) const
{
throw Exception("Op does not implement dynamic property.");
}

OpData::OpData()
: m_metadata()
{ }

OpData::OpData(const OpData & rhs)
: m_metadata()
{
*this = rhs;
}

OpData & OpData::operator=(const OpData & rhs)
{
if (this != &rhs)
{
m_metadata = rhs.m_metadata;
}

return *this;
}

OpDataRcPtr OpData::getIdentityReplacement() const
{
return std::make_shared<MatrixOpData>();
Expand All @@ -70,39 +39,6 @@ void OpData::getSimplerReplacement(OpDataVec & /* ops */) const
{
}

bool OpData::equals(const OpData & other) const
{
if (this == &other) return true;

// Ignore metadata.
return getType() == other.getType();
}

const std::string & OpData::getID() const
{
return m_metadata.getAttributeValueString(METADATA_ID);
}

void OpData::setID(const std::string & id)
{
return m_metadata.setID(id.c_str());
}

const std::string & OpData::getName() const
{
return m_metadata.getAttributeValueString(METADATA_NAME);
}

void OpData::setName(const std::string & name)
{
return m_metadata.setName(name.c_str());
}

bool operator==(const OpData & lhs, const OpData & rhs)
{
return lhs.equals(rhs);
}

const char * GetTypeName(OpData::Type type)
{
switch (type)
Expand Down Expand Up @@ -179,6 +115,8 @@ OpRcPtr Op::getIdentityReplacement() const
{
auto opData = m_data->getIdentityReplacement();
OpRcPtrVec ops;
ops.reserve(1);

if (opData->getType() == OpData::MatrixType)
{
// No-op that will be optimized.
Expand All @@ -198,41 +136,20 @@ OpRcPtr Op::getIdentityReplacement() const
<< std::string(GetTypeName(opData->getType())) << ".";
throw Exception(oss.str().c_str());
}
return ops[0];
return std::move(ops[0]);
}

void Op::getSimplerReplacement(OpRcPtrVec & ops) const
{
OpDataVec opDataVec;
m_data->getSimplerReplacement(opDataVec);
ops.reserve(ops.size() + opDataVec.size());
for (const auto & opData : opDataVec)
{
CreateOpVecFromOpData(ops, opData, TRANSFORM_DIR_FORWARD);
}
}

OpRcPtrVec::OpRcPtrVec()
: m_metadata()
{
}

OpRcPtrVec::OpRcPtrVec(const OpRcPtrVec & v)
: OpRcPtrVec()
{
*this = v;
}

OpRcPtrVec & OpRcPtrVec::operator=(const OpRcPtrVec & v)
{
if(this!=&v)
{
m_ops = v.m_ops;
m_metadata = v.m_metadata;
}

return *this;
}

OpRcPtrVec & OpRcPtrVec::operator+=(const OpRcPtrVec & v)
{
if (this != &v)
Expand All @@ -248,70 +165,6 @@ OpRcPtrVec & OpRcPtrVec::operator+=(const OpRcPtrVec & v)
}
}

OpRcPtrVec::iterator OpRcPtrVec::erase(OpRcPtrVec::const_iterator position)
{
return m_ops.erase(position);
}

OpRcPtrVec::iterator OpRcPtrVec::erase(OpRcPtrVec::const_iterator first,
OpRcPtrVec::const_iterator last)
{
return m_ops.erase(first, last);
}

void OpRcPtrVec::insert(OpRcPtrVec::const_iterator position,
OpRcPtrVec::const_iterator first,
OpRcPtrVec::const_iterator last)
{
m_ops.insert(position, first, last);
}

void OpRcPtrVec::push_back(const OpRcPtrVec::value_type & val)
{
m_ops.push_back(val);
}

OpRcPtrVec::const_reference OpRcPtrVec::back() const
{
return m_ops.back();
}

OpRcPtrVec::const_reference OpRcPtrVec::front() const
{
return m_ops.front();
}

bool OpRcPtrVec::isNoOp() const noexcept
{
for (const auto & op : m_ops)
{
if(!op->isNoOp()) return false;
}

return true;
}

bool OpRcPtrVec::hasChannelCrosstalk() const noexcept
{
return m_ops.end() != std::find_if(m_ops.begin(),
m_ops.end(),
[](const OpRcPtr & op) { return op->hasChannelCrosstalk(); } );
}

bool OpRcPtrVec::isDynamic() const noexcept
{
return m_ops.end() != std::find_if(m_ops.begin(),
m_ops.end(),
[](const OpRcPtr & op) { return op->isDynamic(); } );
}

bool OpRcPtrVec::hasDynamicProperty(DynamicPropertyType type) const noexcept
{
return m_ops.end() != std::find_if(m_ops.begin(),
m_ops.end(),
[type](const OpRcPtr & op) { return op->hasDynamicProperty(type); } );
}

DynamicPropertyRcPtr OpRcPtrVec::getDynamicProperty(DynamicPropertyType type) const
{
for (const auto & op : m_ops)
Expand All @@ -328,10 +181,11 @@ DynamicPropertyRcPtr OpRcPtrVec::getDynamicProperty(DynamicPropertyType type) co
OpRcPtrVec OpRcPtrVec::clone() const
{
OpRcPtrVec cloned;
cloned.reserve(m_ops.size());

for (const auto & op : m_ops)
{
cloned.push_back(op->clone());
cloned.emplace_back(op->clone());
}

return cloned;
Expand All @@ -340,6 +194,7 @@ OpRcPtrVec OpRcPtrVec::clone() const
OpRcPtrVec OpRcPtrVec::invert() const
{
OpRcPtrVec inverted;
inverted.reserve(m_ops.size());

OpRcPtrVec::const_reverse_iterator iter = m_ops.rbegin();
OpRcPtrVec::const_reverse_iterator end = m_ops.rend();
Expand All @@ -361,14 +216,6 @@ OpRcPtrVec OpRcPtrVec::invert() const
return inverted;
}

void OpRcPtrVec::validate() const
{
for (auto & op : m_ops)
{
op->validate();
}
}

namespace
{
template<typename T>
Expand Down Expand Up @@ -473,16 +320,14 @@ std::ostream& operator<< (std::ostream & os, const Op & op)
std::string SerializeOpVec(const OpRcPtrVec & ops, int indent)
{
std::ostringstream oss;
const std::string indentStr(indent, ' ');

for (OpRcPtrVec::size_type idx = 0, size = ops.size(); idx < size; ++idx)
OpRcPtrVec::size_type idx = 0;
for (const auto & op : ops)
{
const OpRcPtr & op = ops[idx];

oss << pystring::mul(" ", indent);
oss << "Op " << idx << ": " << *op << " ";
oss << op->getCacheID();

oss << "\n";
oss << indentStr << "Op " << idx << ": " << *op << " "
<< op->getCacheID() << "\n";
++idx;
}

return oss.str();
Expand Down
Loading
Loading