fstream.cpp: prefer ftello/fseeko(), bitmap.cpp: huge speedup for EXR loading by avoiding fseek calls
parent
82b2e1b8d4
commit
2d9078735e
|
@ -88,11 +88,12 @@ public:
|
|||
EXRIStream(Stream *stream) : IStream(stream->toString().c_str()),
|
||||
m_stream(stream) {
|
||||
m_offset = stream->getPos();
|
||||
m_size = stream->getSize();
|
||||
}
|
||||
|
||||
bool read(char *c, int n) {
|
||||
m_stream->read(c, n);
|
||||
return m_stream->isEOF();
|
||||
return m_stream->getPos() == m_size;
|
||||
}
|
||||
|
||||
Imf::Int64 tellg() {
|
||||
|
@ -106,7 +107,7 @@ public:
|
|||
void clear() { }
|
||||
private:
|
||||
ref<Stream> m_stream;
|
||||
size_t m_offset;
|
||||
size_t m_offset, m_size;
|
||||
};
|
||||
|
||||
class EXROStream : public Imf::OStream {
|
||||
|
|
|
@ -206,7 +206,7 @@ void FileStream::seek(size_t pos) {
|
|||
pos, d->path.string().c_str(), lastErrorText().c_str());
|
||||
}
|
||||
#else
|
||||
if (fseek(d->file, pos, SEEK_SET)) {
|
||||
if (fseeko(d->file, (off_t) pos, SEEK_SET)) {
|
||||
Log(EError, "Error while trying to seek to position %i in file \"%s\": %s",
|
||||
pos, d->path.string().c_str(), strerror(errno));
|
||||
}
|
||||
|
@ -223,8 +223,7 @@ size_t FileStream::getPos() const {
|
|||
}
|
||||
return (size_t) pos;
|
||||
#else
|
||||
long pos;
|
||||
pos = ftell(d->file);
|
||||
off_t pos = ftello(d->file);
|
||||
if (pos == -1) {
|
||||
Log(EError, "Error while looking up the position in file \"%s\": %s",
|
||||
d->path.string().c_str(), strerror(errno));
|
||||
|
|
Loading…
Reference in New Issue