From ecccefcbec2caf5aae5ae6d714cb0584204355b1 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 20 Oct 2019 09:25:30 +0200 Subject: MOHAWK: Cut down on seeks when opening archives Helps with loading times on systems with slow storage. --- engines/mohawk/resource.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/resource.cpp b/engines/mohawk/resource.cpp index e8e382ad00..1e6ded8c8a 100644 --- a/engines/mohawk/resource.cpp +++ b/engines/mohawk/resource.cpp @@ -183,6 +183,7 @@ struct FileTableEntry { }; struct NameTableEntry { + uint16 offset; uint16 index; Common::String name; }; @@ -263,14 +264,15 @@ bool MohawkArchive::openStream(Common::SeekableReadStream *stream) { debug(3, "Names = %04x", nameTable.size()); for (uint16 j = 0; j < nameTable.size(); j++) { - uint16 offset = stream->readUint16BE(); - nameTable[j].index = stream->readUint16BE(); + nameTable[j].offset = stream->readUint16BE(); + nameTable[j].index = stream->readUint16BE(); - debug(4, "Entry[%02x]: Name List Offset = %04x Index = %04x", j, offset, nameTable[j].index); + debug(4, "Entry[%02x]: Name List Offset = %04x Index = %04x", j, nameTable[j].offset, nameTable[j].index); + } + for (uint16 j = 0; j < nameTable.size(); j++) { // Name List - uint32 pos = stream->pos(); - stream->seek(absOffset + stringTableOffset + offset); + stream->seek(absOffset + stringTableOffset + nameTable[j].offset); char c = (char)stream->readByte(); while (c != 0) { nameTable[j].name += c; @@ -278,9 +280,6 @@ bool MohawkArchive::openStream(Common::SeekableReadStream *stream) { } debug(3, "Name = \'%s\'", nameTable[j].name.c_str()); - - // Get back to next entry - stream->seek(pos); } // Resource Table -- cgit v1.2.3