Home » Developing U++ » U++ Developers corner » About string, String and const char *
|
|
Re: About string, String and const char * [message #7418 is a reply to message #7413] |
Thu, 28 December 2006 11:50   |
|
luzr wrote on Thu, 28 December 2006 04:16 | Well, I have just down an interesting investigation (because of some discussion thread in comp.alt.c++.moderated) which also nicely explains why in U++ we are using "const char*" instead of String so often.
#include <string>
void foo(const std::string& x);
void foo2(const char *s);
void Test1()
{
foo("just a test");
}
void Test2()
{
foo2("just a test");
}
Now Test1 has 115 bytes, Test2 12 bytes... (and it is similar for String too).
Mirek
|
Quite huge difference. If Test1 is translated to sth like this:
void Test1()
{
const std::string x("just a test");
foo(x);
}
..it is still interesting that creating string object needs 103 bytes more.
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 18:25:05 CEST 2025
Total time taken to generate the page: 0.00948 seconds
|