You are not logged in.
Pages: 1
Hello,
is it more efficient to type-cast from String to RawUTF8 or to use RawUTF8 directly and implement new functions that return RawUTF8? And is the performance enhancement significant or marginal? I am talking about several million conversions overall.
Edit: Is there a function in TTextWriter that takes a string as an argument and converts it to RawUTF8 internally? I just want to avoid all the warning about implicit type conversions.
Last edited by vennexedu (Yesterday 12:16:07)
Offline
For raw process, using RawUtf8 (or Utf8String) is faster, and avoid most allocations and conversions.
The performance is measurable on a server, especially with multi-threaded process. On a VCL client/app, I don't think it would make a noticeable difference.
A simple rule would be: use RawUtf8 everywhere in your business logic, and use string only when you reach the VCL/UI layer, or some external/legacy code.
You have TTextWriter.AddNoJsonEscapeString() which would make the UTF-8 conversion on the fly, with no temporary allocation.
Online
Thank you! In now use TTextWriter.AddNoJsonEscapeString() instead of AddString and the conversion warnings are gone. I also found AddComma, so instead of writing '),', I can simply use Add(')') and then AddComma. AddNull also comes in handy.
Offline
Pages: 1