You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @mikke89, i bumped into interesting issue. I am making a new gen C# bindings for rbfx with a focus on efficiency. As such, now const char* is wrapped as ReadOnlySpan<byte> and eastl::string/std::string are wrapped as Ea.String/Std.String types that are distinct from C# string. All that in order to avoid C# string which creates a constant pressure on GC. When it comes to RmlUi - it uses const String& everywhere. In C++ this is less of an issue due to SBO, but with C# bindings this means a mandatory C++ object allocation. Using std::string_view here would relieve this pressure - it becomes possible to pass a simple raw UTF-8 string pointer and have C++ figure out whether to store it or not. Admittedly rbfx is also guilty of this anti-pattern and we are slowly trying to move away from it. What do you think about using std::string_view instead of const std::string& for interfaces? I know, change is not trivial, but if it could happen then it would benefit C++ as well, not only foreign languages as in my case.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @mikke89, i bumped into interesting issue. I am making a new gen C# bindings for rbfx with a focus on efficiency. As such, now
const char*is wrapped asReadOnlySpan<byte>andeastl::string/std::stringare wrapped asEa.String/Std.Stringtypes that are distinct from C#string. All that in order to avoid C#stringwhich creates a constant pressure on GC. When it comes to RmlUi - it usesconst String&everywhere. In C++ this is less of an issue due to SBO, but with C# bindings this means a mandatory C++ object allocation. Usingstd::string_viewhere would relieve this pressure - it becomes possible to pass a simple raw UTF-8 string pointer and have C++ figure out whether to store it or not. Admittedly rbfx is also guilty of this anti-pattern and we are slowly trying to move away from it. What do you think about usingstd::string_viewinstead ofconst std::string&for interfaces? I know, change is not trivial, but if it could happen then it would benefit C++ as well, not only foreign languages as in my case.Beta Was this translation helpful? Give feedback.
All reactions