Re: [cpp] Re: 如何优雅地获取string 对象的可写缓冲区

Lingoes lingoes at gmail.com
Tue Dec 5 12:04:03 CST 2006


>
> 你的代码真是就是需要为减少这一个比较操作而优化吗?!


得到内存指针进行操作, 关键是为了性能, 你可以仔细看一下 [] 操作符的源代码, 就会明白其间性能相差是非常大的, 这个对少量的赋值操作可能不明显,
但如果数据量一大, 就会明显反映出来.

另外, 由于 string 对象的 copy on write 机制, 直接从c_str() 取地址, 是不可以的, 你需要补习一下功课了
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20061205/d97c8786/attachment.html


More information about the Cpp mailing list