I happened to find a piece of code like this:
// other people's implementation
Obj obj;
stringstream ss;
ofstream outfile("save.pth");
ss.write((char*)obj.data(), obj.size());
outfile << ss.rdbuf();
I think directly write to ofstream would be faster, like this:
// my approach
Obj obj;
ofstream outfile("save.pth");
outfile.write((char*obj).data(), obj.size());
Why some people would like to use stringstream to pass the data?
Aucun commentaire:
Enregistrer un commentaire