mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
tools: spiffsgen.py: avoid reallocating byte array for each new block
On large filesystems (~15 MB), this reduces execution time from 11s to 0.3s.
This commit is contained in:
parent
ad1606ae1d
commit
930ee51b8f
@ -448,19 +448,21 @@ class SpiffsFS():
|
||||
|
||||
def to_binary(self):
|
||||
img = b''
|
||||
all_blocks = []
|
||||
for block in self.blocks:
|
||||
img += block.to_binary(self.blocks_lim)
|
||||
all_blocks.append(block.to_binary(self.blocks_lim))
|
||||
bix = len(self.blocks)
|
||||
if self.build_config.use_magic:
|
||||
# Create empty blocks with magic numbers
|
||||
while self.remaining_blocks > 0:
|
||||
block = SpiffsBlock(bix, self.blocks_lim, self.build_config)
|
||||
img += block.to_binary(self.blocks_lim)
|
||||
all_blocks.append(block.to_binary(self.blocks_lim))
|
||||
self.remaining_blocks -= 1
|
||||
bix += 1
|
||||
else:
|
||||
# Just fill remaining spaces FF's
|
||||
img += '\xFF' * (self.img_size - len(img))
|
||||
all_blocks.append(b'\xFF' * (self.img_size - len(img)))
|
||||
img += b''.join([blk for blk in all_blocks])
|
||||
return img
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user