Arnold String allows for fast string comparisons. More...
#include <ai_string.h>
Public Member Functions | |
AtString (const char *str) | |
Creating an AtString from a char* is an expensive operation. More... | |
AI_DEVICE bool | operator== (const AtString &rhs) const |
Comparing two AtString objects is an extremely fast pointer comparison. | |
AI_DEVICE bool | operator!= (const AtString &rhs) const |
size_t | length () const |
Computing the length is a fast constant time operation. | |
bool | empty () const |
Returns true if underlying char* is NULL or "". | |
operator const char * () const | |
AtString will automatically call c_str() in most situations and so can be automatically used in places that expect a char* . More... | |
AI_DEVICE const char * | c_str () const |
Returns the string as a const char* . More... | |
AI_DEVICE void | clear () |
AI_DEVICE size_t | hash () const |
Returns a hashed version of the string. More... | |
Arnold String allows for fast string comparisons.
Since it is expensive to create, try to create an AtString once in a preprocess, for instance in node_initialize
, and then reuse it instead of creating it over and over, for instance, in shader_evaluate
where it could get called millions of times. For string constants, use a static const
in the function, or better yet, in the global scope:
The underlying string data contained by an AtString will exist over the entire lifetime of the Arnold library. If you unload the Arnold library in your process, any AtString objects still in existence will become invalid and using them will likely result in a crash or other undefined behavior.