Skip to content

Commit

Permalink
Utilize string_view initialization of TfToken in path parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmkuruc committed May 31, 2024
1 parent 92b130b commit 9c0d0fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
5 changes: 5 additions & 0 deletions pxr/usd/sdf/pathParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ using namespace PXR_PEGTL_NAMESPACE;

namespace Sdf_PathParser {

template <class Input>
TfToken GetToken(Input const &in) {
return TfToken{in.string_view()};
}

template <>
struct Action<ReflexiveRelative> {
template <class Input>
Expand Down
19 changes: 0 additions & 19 deletions pxr/usd/sdf/pathParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,6 @@ struct PPContext {
std::string varName;
};

template <class Input>
TfToken GetToken(Input const &in) {
constexpr int BufSz = 32;
char buf[BufSz];
size_t strSize = std::distance(in.begin(), in.end());
TfToken tok;
if (strSize < BufSz) {
// copy & null-terminate.
std::copy(in.begin(), in.end(), buf);
buf[strSize] = '\0';
tok = TfToken(buf);
}
else {
// fall back to string path.
tok = TfToken(in.string());
}
return tok;
}

template <class Rule>
struct Action : PEGTL_NS::nothing<Rule> {};

Expand Down

0 comments on commit 9c0d0fb

Please sign in to comment.