Home » Community » U++ community news and announcements » String & strlen optimization, force_inline in defs.h
String & strlen optimization, force_inline in defs.h [message #34620] |
Fri, 02 December 2011 09:53 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
When strlen is intrinsic and applied to string literal, both compilers are able to replace it with constant.
That has a huge impact when we do things like
String s = "Hello ";
s << "world!";
because it is possible that we completely avoid scanning literal for its length (second command is then equivalent to Cat("world!", 6)).
Now this always worked (without me actually knowing quite well in GCC, except some String methods that did have strlen hidden in .cpp file.
Not so easy with MSC, which stubbornly refuses to inline some things and needs strlen to be activated as intrinsics.
Anyway, by combination of techniques, both compiler should be now able to optimize out strlen in most common cases.
In the process, I have added "force_inline" macro (thanks for hinting that out, Novo) to hide differences between MSC (__force_inline) and GCC (declspace(always_inline) inline).
Mirek
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 06:05:39 CEST 2024
Total time taken to generate the page: 0.05779 seconds
|