Skip to content

Commit

Permalink
Merge pull request #54 from yaroslav-o/master
Browse files Browse the repository at this point in the history
Use bytearray for greatly improved file processing performance
  • Loading branch information
jrspruitt authored Jan 17, 2022
2 parents 175f7fa + e2f63dc commit 38d3706
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ubireader/ubifs/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def file_leng(ubifs, inode):

def _process_reg_file(ubifs, inode, path):
try:
buf = b''
buf = bytearray()
if 'data' in inode:
compr_type = 0
sorted_data = sorted(inode['data'], key=lambda x: x.key['khash'])
Expand Down Expand Up @@ -177,4 +177,4 @@ def _process_reg_file(ubifs, inode, path):
if inode['ino'].size > len(buf):
buf += b'\x00' * (inode['ino'].size - len(buf))

return buf
return bytes(buf)
4 changes: 2 additions & 2 deletions ubireader/ubifs/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _write_reg_file(path, data):

def _process_reg_file(ubifs, inode, path):
try:
buf = b''
buf = bytearray()
if 'data' in inode:
compr_type = 0
sorted_data = sorted(inode['data'], key=lambda x: x.key['khash'])
Expand Down Expand Up @@ -194,4 +194,4 @@ def _process_reg_file(ubifs, inode, path):
if inode['ino'].size > len(buf):
buf += b'\x00' * (inode['ino'].size - len(buf))

return buf
return bytes(buf)

0 comments on commit 38d3706

Please sign in to comment.