Boris Vidolov
2003-09-30 09:55:50 UTC
Hello all,
Maybe you have noticed that the new std::string object is not reference
counted. Consider this code:
string s = "This is one loooooooooong string..................";
string t = s;
In this case the whole long memory is copied to the buffer of variable t,
which is significantly slower than the old version of std::string - in it we
simply increment the proper reference counter and set t to point to the same
string. This technique is very fast in copying and is widely (I personally
have created at about 20 different classes, implementing the refcounted
technique).
The question is why in the last version of Microsoft Visual C++ this
mechinism is suppressed. A colleague of mine joked, that thus we could
compile a C++ code, using std::string, than a C# code, which string is
possibly refcounted and then say: see the C++ code is even slower than the
C# one! C# is even faster than C++ :) This would be a good marketing trick,
but behind the scenes what is the real reason for removing refcounted
internal object from std::string?
Regards,
Boris
Maybe you have noticed that the new std::string object is not reference
counted. Consider this code:
string s = "This is one loooooooooong string..................";
string t = s;
In this case the whole long memory is copied to the buffer of variable t,
which is significantly slower than the old version of std::string - in it we
simply increment the proper reference counter and set t to point to the same
string. This technique is very fast in copying and is widely (I personally
have created at about 20 different classes, implementing the refcounted
technique).
The question is why in the last version of Microsoft Visual C++ this
mechinism is suppressed. A colleague of mine joked, that thus we could
compile a C++ code, using std::string, than a C# code, which string is
possibly refcounted and then say: see the C++ code is even slower than the
C# one! C# is even faster than C++ :) This would be a good marketing trick,
but behind the scenes what is the real reason for removing refcounted
internal object from std::string?
Regards,
Boris