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
mirek is currently offline  mirek
Messages: 13442
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, 18 September 2021 17:31]

Report message to a moderator

Previous Topic: text<->double conversions refactored
Next Topic: 32 bit wchar - for now in branch
Goto Forum:
  


Current Time: Mon Oct 25 15:59:03 CEST 2021

Total time taken to generate the page: 0.00995 seconds