[ scummvm-Patches-2838562 ] Improve endian.h and stream.h

SourceForge.net noreply at sourceforge.net
Sun Aug 16 17:47:12 CEST 2009


Patches item #2838562, was opened at 2009-08-16 17:47
Message generated for change (Tracker Item Submitted) made by nolange
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418822&aid=2838562&group_id=37116

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Norbert Lange (nolange)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improve endian.h and stream.h

Initial Comment:
I improved endian.h and stream.h in various ways, resulting in a notable size-reduction for the scummvm executeable.
x86 architectures likely have the biggest improvment, due having a bswap instruction and good support under gcc  (other archtectures just have a generic software-fallback for the byteswap-builtin instead using optimized versions).

On another note, some code assumes that Stream::readByte does return 0 in case of an error, even if the comments are very clear that shouldnt be expected. (xmplparser class for example). Thus the patch still emulates that behaviour.

endian.h:
*) dont use additions if an or is sufficient - this eases up optimization work for the compiler (SWAP_BYTES_16 is now 1 instruction instead of 5 on x86)
*) use byteswap-builtin if compiler supports it. (SWAP_BYTES_32 is now 1 instruction instead of 13 on x86).
*) use compiler-support for unaligned loads, this should reduce instruction count on CPUs which have special support for this (MIPS)
stream.h:
*) use funtions from endian.h where possible
*) avoid multiple virtual-calls in the read/write stream funtions, compilers cant inline them
*) made _bigEndian constant and private in MemoryReadStreamEndian and SeekableSubReadStreamEndian
engines/saga/animation.cpp:
*) fixed an access to MemoryReadStreamEndian::_bigEndian


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418822&aid=2838562&group_id=37116




More information about the Scummvm-tracker mailing list