A couple optimizations to file load speeds
This commit is contained in:
parent
c71ea2616e
commit
66bd8bbec8
11
read_in.py
11
read_in.py
|
@ -36,10 +36,11 @@ def read_single_elevation(dat: str) -> Result[int, str]:
|
|||
>>> read_single_elevation("10.0m")
|
||||
Err('10.0m')
|
||||
"""
|
||||
return map_res(
|
||||
meters_to_millimeters, # fuck floating points
|
||||
try_(replace(dat), float, dat)
|
||||
)
|
||||
try:
|
||||
# fuck floating points
|
||||
return Ok(meters_to_millimeters(float(dat)))
|
||||
except ValueError:
|
||||
return Err(dat)
|
||||
|
||||
def read_elevation_line(line: str) -> Result[Sequence[int], Tuple[int, str]]:
|
||||
"""
|
||||
|
@ -186,7 +187,7 @@ def load_gb_pixels_as_map(pixels: Iterable[Tuple[int, int]]) -> Result[Sequence[
|
|||
"""
|
||||
return sequence([
|
||||
note(
|
||||
UnrecognizedColor(pix_no % 395, pix_no // 395),
|
||||
lambda: UnrecognizedColor(pix_no % 395, pix_no // 395),
|
||||
gb_to_terrain_type(gb)
|
||||
)
|
||||
for (pix_no, gb) in enumerate(pixels)
|
||||
|
|
Loading…
Reference in a new issue