Currently, every call of DisplayedString does a marshalling from/to C and copying of the string data.
If you update the Text instance often (e.g. FPS counter), than we're wasting a lot of processing time to convert and allocate memory to get the string data.
It would be less expensive too cache the string data on C# side. As there isn't anything on SFML's side that could lead to a change of the string on its own, it should be fine to update the string data in the set method and have return only return the cached value.
Three (?) edge cases to consider:
set has never been called
Text instance was copied
CPointer changes somehow
See also forum thread.
Currently, every call of DisplayedString does a marshalling from/to C and copying of the string data.
If you update the Text instance often (e.g. FPS counter), than we're wasting a lot of processing time to convert and allocate memory to get the string data.
It would be less expensive too cache the
stringdata on C# side. As there isn't anything on SFML's side that could lead to a change of the string on its own, it should be fine to update the string data in the set method and have return only return the cached value.Three (?) edge cases to consider:
sethas never been calledTextinstance was copiedCPointerchanges somehowSee also forum thread.