Open homm opened 2 years ago
This improves usage of standard struct module. unpack_from function doesn't require extra copying as well as doesn't require data length match.
struct
unpack_from
Also there was a several places where sequence of unpack calls can be replaced with single call.
unpack
- tag = struct.unpack(self.endian_mark + "H", - self.tiftag[pointer: pointer+2])[0] - value_type = struct.unpack(self.endian_mark + "H", - self.tiftag[pointer + 2: pointer + 4])[0] - value_num = struct.unpack(self.endian_mark + "L", - self.tiftag[pointer + 4: pointer + 8] - )[0] + tag, value_type, value_num = unpack_from( + self.endian_mark + "HHL", self.tiftag, pointer)
This improves usage of standard
struct
module.unpack_from
function doesn't require extra copying as well as doesn't require data length match.Also there was a several places where sequence of
unpack
calls can be replaced with single call.