From 47b847a7865536ba09003687078efb25ce8e0d97 Mon Sep 17 00:00:00 2001 From: Matt Kuruc Date: Wed, 15 Nov 2023 13:34:51 -0800 Subject: [PATCH] Guard against unnecessary array detaches in attribute creation --- pxr/usd/usd/schemaRegistry.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pxr/usd/usd/schemaRegistry.cpp b/pxr/usd/usd/schemaRegistry.cpp index 9ee1af195c..39ca9ce959 100644 --- a/pxr/usd/usd/schemaRegistry.cpp +++ b/pxr/usd/usd/schemaRegistry.cpp @@ -1330,7 +1330,7 @@ BuildPrimDefinition(_SchemaDefInitHelper *defInitHelper) // Get the list of names of any override properties this schema may have as // we want to skip these at first when initializing the prim definition. - VtTokenArray overridePropertyNames = _GetOverridePropertyNames( + const VtTokenArray overridePropertyNames = _GetOverridePropertyNames( schematicsLayer, schematicsPrimPath); // Multiple apply schemas are actually templates for creating an instance of @@ -1455,7 +1455,8 @@ BuildPrimDefinition(_SchemaDefInitHelper *defInitHelper) // With all the built-in API schemas composed in, we can now compose any // API schema property overrides declared in this API schema over the // defined properties. - for (const TfToken &overridePropertyName : overridePropertyNames) { + for (const TfToken &overridePropertyName : + overridePropertyNames.AsConst()) { primDef->_ComposeOverAndReplaceExistingProperty( overridePropertyName, schematicsLayer, @@ -1535,7 +1536,7 @@ _PopulateConcretePrimDefinitions() const const SdfPath schematicsPrimPath = SdfPath::AbsoluteRootPath().AppendChild(schemaInfo->identifier); - VtTokenArray overridePropertyNames = _GetOverridePropertyNames( + const VtTokenArray overridePropertyNames = _GetOverridePropertyNames( schematicsLayer, schematicsPrimPath); // Create and initialize a new prim definition for the concrete schema. @@ -1565,7 +1566,8 @@ _PopulateConcretePrimDefinitions() const // With all the built-in API schemas applied, we can now compose any // API schema property overrides declared in the typed schema over the // current defined properties. - for (const TfToken &overridePropertyName : overridePropertyNames) { + for (const TfToken &overridePropertyName : + overridePropertyNames.AsConst()) { primDef->_ComposeOverAndReplaceExistingProperty( overridePropertyName, schematicsLayer,