libjimage abstracts away endianness using the Endian class. It does so using virtual and having concrete classes for swapping and native. In C++ calls to virtual functions are not free and typically require a vtable lookup. Since this code is used during startup, it probably should be as fast as feasible.
Instead an enumeration representing the endianness should be used and functions on Endian should be made static and defined in the header. This will allow the compiler to optimize usages, including inlining, in addition to avoiding virtual calls. The enumeration representing the endianness would be passed around in place of a pointer to Endian, Endian would take the enumeration as the first argument to its methods.
Instead an enumeration representing the endianness should be used and functions on Endian should be made static and defined in the header. This will allow the compiler to optimize usages, including inlining, in addition to avoiding virtual calls. The enumeration representing the endianness would be passed around in place of a pointer to Endian, Endian would take the enumeration as the first argument to its methods.