C++:最佳文本累加器
文本在发送给客户端之前会逐渐积累。
现在我们使用自己的类为每个块分配内存作为 char 块。 (无论如何,工作方式类似于 char[][]
+ std::list
)。
然后我们构建整个字符串,将其转换为 std::sting,然后使用它创建 boost::asio::streambuf。我想这已经足够慢了。如果我错了请纠正我。
我知道,在许多情况下,使用 stdio.h
中的简单 FILE
类型。它是如何运作的?每次写入时分配内存。那么,它更快吗?有什么方法可以从 FILE
读取 boost::asio::streambuf
吗?
添加:嗯。我忘记了一件大事:)。 dll和主应用程序的编译是在少数编译器下进行的,因此它内部不应该有stl的东西......因为它在执行dll时通常会导致很多问题。
Text gets accumulates piecemeal before being sent to client.
Now we use own class that allocates memory for each piece as char massive. (Anyway, works like char[][]
+ std::list<char*>
).
Then we build the whole string, convert it into std::sting and then create boost::asio::streambuf
using it. That's slow enough, I assume. Correct me if I'm wrong.
I know, in many cases simple FILE
type from stdio.h
is used. How does it works? Allocates memory at every write into it. So, is it faster and is there any way to read into boost::asio::streambuf
from FILE
?
ADD: Hm. I've forgot one big thing :). The compilation of dlls and main application is made under few compilers, so it should have no stl stuff inside it ... Because it usually cause a lot of problems, while executing dlls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看http://www.sgi.com/tech/stl/Rope.html< /a>
Check out http://www.sgi.com/tech/stl/Rope.html
我不知道它的效率有多高,但我通常使用 ostringstream 来做这类事情
I have no idea how efficient it is, but I usually use a ostringstream for that sort of thing