Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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: 13975
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: Wed Apr 17 01:56:00 CEST 2024

Total time taken to generate the page: 0.02067 seconds