存储增量下载数据的最佳方式是什么?
受到 Chromium 的 sha1 类 的启发,我正在考虑增量存储使用 std::string 下载数据
// pseudo-code
char buff[BUFF_SIZE];
std::string data;
do {
size = ReadInternetFileTo(buff,BUFF_SIZE);
data.append(buff,size);
} while (not_finished);
此方法或更好的方法有任何可预见的问题吗?
Inspired by Chromium's sha1 class, I am thinking to store incrementally downloaded data using std::string
// pseudo-code
char buff[BUFF_SIZE];
std::string data;
do {
size = ReadInternetFileTo(buff,BUFF_SIZE);
data.append(buff,size);
} while (not_finished);
Any foreseeable problems with this method or better way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你的数据很大并且你可以使用 SGI 的 STL —— 正如他们的文档所说,
SGI's good old Rope seems like a great fit, if your data's large and you can use SGI's STL -- as their docs say,
应该没问题,但您可能需要考虑用绳子而不是绳子。附加到绳索更有效,因为它不能保证所有字节保持连续,这将需要重新分配。
Should be OK, but you may want to consider rope instead of string. It is more efficient to append to a rope, as it won't promise to keep all bytes consecutive, which will require a reallocation.