On segunda-feira, 5 de agosto de 2013 21:08:45, Rollastre Prostrit wrote: > QByteArray bytes = f.readAll(); > > char* bb = bytes.data(); > std::string str; > for (int i=0; i<f.size(); ++i) > { > str += bb[i]; > } > > std::stringstream stream; > stream << str;
That seems wrong or, at least, weird. You're appending byte-by-byte from the file into the string. That can't be fast... Doesn't std::string have a method that lets you set a full array of bytes (pointer and size)? Or, for that matter, doesn't stringstream have it? I confess I don't know: the lack of such convenience API is what keeps me from using the Standard Library. Another alternative is for you to derive from std::istream and create your own QFile-based stream. Or a QByteArray-based one, to match std::stringstream. At the very least, to make it more efficient, you should try to use QFile::map(). For uncompressed resources, this will save you a memory allocation into the QByteArray. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest