]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Use bytearray instead of string
authorSimon Glass <sjg@chromium.org>
Tue, 6 Jul 2021 16:36:39 +0000 (10:36 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 21 Jul 2021 16:27:35 +0000 (10:27 -0600)
This is faster if data is being concatenated. Update the section and
collection etypes.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/collection.py
tools/binman/etype/section.py

index 1625575fe98af32a0e88c9b0ab2dc7e189f71937..442b40b48b3e5cda5ef76ecbc6ff48f924744766 100644 (file)
@@ -40,7 +40,7 @@ class Entry_collection(Entry):
         """
         # Join up all the data
         self.Info('Getting contents, required=%s' % required)
-        data = b''
+        data = bytearray()
         for entry_phandle in self.content:
             entry_data = self.section.GetContentsByPhandle(entry_phandle, self,
                                                            required)
index 92d3f3add4ce9b4ece7a26b91bd0b21fbc17688c..e2949fc9163fe4b89dc38e44f31b6a24871d38a9 100644 (file)
@@ -166,7 +166,7 @@ class Entry_section(Entry):
         pad_byte = (entry._pad_byte if isinstance(entry, Entry_section)
                     else self._pad_byte)
 
-        data = b''
+        data = bytearray()
         # Handle padding before the entry
         if entry.pad_before:
             data += tools.GetBytes(self._pad_byte, entry.pad_before)
@@ -200,7 +200,7 @@ class Entry_section(Entry):
         Returns:
             Contents of the section (bytes)
         """
-        section_data = b''
+        section_data = bytearray()
 
         for entry in self._entries.values():
             entry_data = entry.GetData(required)