Skip to content

Commit c286cee

Browse files
Static analysis optimizations
This changelist addresses a handful of static analysis optimizations flagged by PVS-Studio and cppcheck.
1 parent 41ec46d commit c286cee

6 files changed

Lines changed: 12 additions & 13 deletions

File tree

source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void ClosureLayerNodeMdl::emitFunctionCall(const ShaderNode& _node, GenContext&
159159
}
160160

161161
void ClosureLayerNodeMdl::emitBsdfOverBsdfFunctionCalls(
162-
ShaderNode& node,
162+
const ShaderNode& node,
163163
GenContext& context,
164164
ShaderStage& stage,
165165
const ShaderGenerator& shadergen,
@@ -231,7 +231,7 @@ void ClosureLayerNodeMdl::emitBsdfOverBsdfFunctionCalls(
231231
}
232232

233233
void ClosureLayerNodeMdl::emitBsdfOverBsdfFunctionCalls_thinFilm(
234-
ShaderNode& node,
234+
const ShaderNode& node,
235235
GenContext& context,
236236
ShaderStage& stage,
237237
const ShaderGenerator& shadergen,

source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class MX_GENMDL_API ClosureLayerNodeMdl : public CarryThinFilmParameters<ShaderN
7676
void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
7777

7878
void emitBsdfOverBsdfFunctionCalls(
79-
ShaderNode& node,
79+
const ShaderNode& node,
8080
GenContext& context,
8181
ShaderStage& stage,
8282
const ShaderGenerator& shadergen,
@@ -85,7 +85,7 @@ class MX_GENMDL_API ClosureLayerNodeMdl : public CarryThinFilmParameters<ShaderN
8585
ShaderOutput* output) const;
8686

8787
void emitBsdfOverBsdfFunctionCalls_thinFilm(
88-
ShaderNode& node,
88+
const ShaderNode& node,
8989
GenContext& context,
9090
ShaderStage& stage,
9191
const ShaderGenerator& shadergen,

source/MaterialXGenShader/UnitSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ UnitTransform::UnitTransform(const string& ss, const string& ts, const TypeDesc*
118118

119119
const string UnitSystem::UNITSYTEM_NAME = "default_unit_system";
120120

121-
UnitSystem::UnitSystem(const string& target)
121+
UnitSystem::UnitSystem(const string& target) :
122+
_target(createValidName(target))
122123
{
123-
_target = createValidName(target);
124124
}
125125

126126
void UnitSystem::loadLibrary(DocumentPtr document)

source/MaterialXGenShader/UnitSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class MX_GENSHADER_API UnitSystem
8585

8686
protected:
8787
// Protected constructor
88-
UnitSystem(const string& language);
88+
UnitSystem(const string& target);
8989

9090
protected:
9191
UnitConverterRegistryPtr _unitRegistry;

source/MaterialXGraphEditor/Graph.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,13 +3509,12 @@ void Graph::shaderPopup()
35093509
void Graph::handleRenderViewInputs(ImVec2 minValue, float width, float height)
35103510
{
35113511
ImVec2 mousePos = ImGui::GetMousePos();
3512-
mx::Vector2 mxMousePos = mx::Vector2(mousePos.x, mousePos.y);
3513-
ImVec2 dragDelta = ImGui::GetMouseDragDelta();
3514-
float scrollAmt = ImGui::GetIO().MouseWheel;
3515-
int button = -1;
3516-
bool down = false;
35173512
if (mousePos.x > minValue.x && mousePos.x < (minValue.x + width) && mousePos.y > minValue.y && mousePos.y < (minValue.y + height))
35183513
{
3514+
mx::Vector2 mxMousePos = mx::Vector2(mousePos.x, mousePos.y);
3515+
float scrollAmt = ImGui::GetIO().MouseWheel;
3516+
int button = -1;
3517+
bool down = false;
35193518
if (ImGui::IsMouseDragging(0) || ImGui::IsMouseDragging(1))
35203519
{
35213520
_renderer->setMouseMotionEvent(mxMousePos);

source/PyMaterialX/PyMaterialXCore/PyElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void bindPyElement(py::module& mod)
9090
.def("hasSourceUri", &mx::Element::hasSourceUri)
9191
.def("getSourceUri", &mx::Element::getSourceUri)
9292
.def("getActiveSourceUri", &mx::Element::getActiveSourceUri)
93-
.def("validate", [](mx::Element& elem)
93+
.def("validate", [](const mx::Element& elem)
9494
{
9595
std::string message;
9696
bool res = elem.validate(&message);

0 commit comments

Comments
 (0)