From 55f6e4307ffa873a9d188c8937cd5fd95146dbfc Mon Sep 17 00:00:00 2001 From: krcroft Date: Wed, 5 Feb 2020 23:10:40 -0800 Subject: [PATCH] Simplify ISO size calculation This is simplified by no longer retaining the read position, which is unecessary because all read operations are offset from an initial absolute position (so this was unecessary code). --- src/dos/cdrom_image.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dos/cdrom_image.cpp b/src/dos/cdrom_image.cpp index 8a14b533..ffe5be06 100644 --- a/src/dos/cdrom_image.cpp +++ b/src/dos/cdrom_image.cpp @@ -83,13 +83,19 @@ bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, int seek, int count) int CDROM_Interface_Image::BinaryFile::getLength() { // Guard: only proceed with a valid file - if (file == nullptr) return -1; + if (file == nullptr) + return -1; - std::streampos original_pos = file->tellg(); + // All read operations involve an absolute position and + // this function isn't called in other threads, therefore + // we don't need to retain the original read position. file->seekg(0, ios::end); const int length = static_cast(file->tellg()); - file->seekg(original_pos, ios::end); +#ifdef DEBUG + LOG_MSG("CDROM: BinaryLength (in milliseconds) = %d", length); +#endif return length; + } Bit16u CDROM_Interface_Image::BinaryFile::getEndian()