Skip to content

Commit

Permalink
Simplify syzygy.Table.init_mmap()
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jan 7, 2023
1 parent 9cb8d3b commit 3fd1188
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions chess/syzygy.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,7 @@ def __init__(self, path: str, *, variant: Type[chess.Board] = chess.Board) -> No
self.enc_type = 1 + j

def init_mmap(self) -> None:
if self.data is not None:
return

with self.write_lock:
if self.data is not None:
return

if self.data is None:
fd = os.open(self.path, os.O_RDONLY | os.O_BINARY if hasattr(os, "O_BINARY") else os.O_RDONLY)
try:
data = mmap.mmap(fd, 0, access=mmap.ACCESS_READ)
Expand Down

0 comments on commit 3fd1188

Please sign in to comment.