U++ framework
Do not panic. Ask here before giving up.

Home » Community » U++ community news and announcements » String::Make - new way how to create a small string fast
String::Make - new way how to create a small string fast [message #57545] Sat, 18 September 2021 17:31 Go to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
While optimizing conversion routines, I have found a relative bottleneck when converting small char buffers to String. To solve that, there is now a new static method


template <class Maker> static String Make(int alloc, Maker m)


Optimized static method for creating Strings. This method creates internal buffer of at least alloc and then invokes lambda m passing the char * pointer to the internal buffer as lambda parameter. Lambda is then supposed to fill the characters to this buffer and return the length of string (which must be <= alloc). For the best performance, alloc should be constant.

Example:

String x = String::Make(12, [](char *t) { *t++ = 'X'; return 1; });

[Updated on: Sat, 26 February 2022 18:51]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merry Christmas and Happy New Year 2022!
Next Topic: IME improved support
Goto Forum:
  


Current Time: Sun Jun 28 13:03:29 GMT+2 2026

Total time taken to generate the page: 0.00749 seconds