mirror of
https://github.com/Steffo99/lihzahrd.git
synced 2024-11-21 23:54:23 +00:00
Optimize _read_tile_block (10s gain!)
This commit is contained in:
parent
985644e4b1
commit
8e4f115d90
1 changed files with 6 additions and 4 deletions
|
@ -240,7 +240,7 @@ class World:
|
||||||
self.shadow_orbs = value
|
self.shadow_orbs = value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _read_tile_block(fr: FileReader, tileframeimportant) -> List:
|
def _read_tile_block(fr: FileReader, tileframeimportant) -> Tuple[Tile, int]:
|
||||||
# Once again, this code is a mess
|
# Once again, this code is a mess
|
||||||
flags1 = fr.bits()
|
flags1 = fr.bits()
|
||||||
has_block = flags1[1]
|
has_block = flags1[1]
|
||||||
|
@ -320,7 +320,7 @@ class World:
|
||||||
multiply_by = 1
|
multiply_by = 1
|
||||||
# Create tile
|
# Create tile
|
||||||
tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring)
|
tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring)
|
||||||
return [tile] * multiply_by
|
return tile, multiply_by
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_classic(self):
|
def is_classic(self):
|
||||||
|
@ -351,8 +351,10 @@ class World:
|
||||||
while tm.size.x < world_size.x:
|
while tm.size.x < world_size.x:
|
||||||
column = []
|
column = []
|
||||||
while len(column) < world_size.y:
|
while len(column) < world_size.y:
|
||||||
readtiles = cls._read_tile_block(f, tileframeimportant)
|
tile, multiply_by = cls._read_tile_block(f, tileframeimportant)
|
||||||
column = [*column, *readtiles]
|
for _ in range(multiply_by):
|
||||||
|
# This works by reference, and stops working if write support is added
|
||||||
|
column.append(tile)
|
||||||
tm.add_column(column)
|
tm.add_column(column)
|
||||||
return tm
|
return tm
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue