Skip to content

Conversation

@homm
Copy link

@homm homm commented Jan 19, 2022

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.

-            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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant