BehaviorTree/BehaviorTree.CPP

change signature of registerNodeType to accept StringView

stewpend0us opened this issue · 3 comments

As far as I can tell...right now registerNodeType requires a const std::string& ID but ultimately just makes a copy of the string anyway. Why not use StringView instead?

That way I can keep a static constexpr StringView ID on my class and pass it directly into registerNodeType<MyType>(MyType::ID, ...) without having to jump through the (very small) extra hoop of defining a static const std::string

Better yet (maybe?) allow me to optionally define my class with a static constexpr StringView ID property that just gets picked up by the register function?

feel free to submit a PR

So, I see that there could be 1 copy of a string less during initialization, but since this run-time optimization only happens at the very beginning, when the node is registered, it is not a good reason to apply a non-ABI compatible change

Sorry. I can do what I need with the "registrationName()" method.