定期地
这样地:
for(unsigned int j = 0; j < Count; ++j) {
// Fill out QByteArray my_ba in every single iteration of the loop
// ...
// But write my_ba only periodically and then clear it!
// period is picked in such a way that writing to file will be done for every 1MB of data
if( j % period == 0){
if(file){
file->write(my_ba);
file->flush();
my_ba.clear();
}
}
// ...
}
我清除了我的
QByteArray
周期性地做
my_ba.clear()
将其内容写入文件后,因此
QByteArray
因此减少了费用。