6 comments

[ 2.5 ms ] story [ 21.7 ms ] thread
Why not just use C++ strings and string_views? So weird to see this masochistic obsession some people have with doing everything in plain C.

It's 2026, there are better, more memory safe, more efficient solutions out there.

I'm surprised this is aliased to char*, not const char*. The benefit of the aliasing is convenience, but the main risk is absent-mindedly passing it to a libc function that modifies the string without updating the SDS metadata. Const would result in a compiler warning while letting the intended use cases (e.g., the printf example) work fine.
Hi! The Redis tree contains more advanced versions of this library. Most of the development continued there, eventually.
Was:

  s = sdscat(s,"Some more data");
Chosen over

  stscat(&s, "Some more data");
For performance reasons, or something else?