PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.45k stars 1.13k forks source link

Utilize `string_view` initialization of `TfToken` in path parsing #3054

Open nvmkuruc opened 3 weeks ago

nvmkuruc commented 3 weeks ago

Description of Change(s)

(Depends on #3053)

GetToken tries to minimize dynamic allocations during path parsing by utilizing a stack allocated char[32] that can be explicitly NULL-terminated. This optimization still involves a copy to the intermediate buffer and only works for short strings.

This changes GetToken to use the new std::string_view constructor for TfToken instead. When the components of the path already exist in the registry, no copies or allocations are required. We've seen performance gains of about 4-8% in a simple test case where all the path components already exist as tokens.

Fixes Issue(s)

-

jesschimein commented 3 weeks ago

Filed as internal issue #USD-9589

jesschimein commented 3 weeks ago

/AzurePipelines run

azure-pipelines[bot] commented 3 weeks ago
Azure Pipelines successfully started running 1 pipeline(s).