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)
-
[ ] I have verified that all unit tests pass with the proposed changes
[x] I have submitted a signed Contributor License Agreement
Description of Change(s)
(Depends on #3053)
GetToken
tries to minimize dynamic allocations during path parsing by utilizing a stack allocatedchar[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 newstd::string_view
constructor forTfToken
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)
-