Skip to content

Commit

Permalink
Avoid repeated handler lookups.
Browse files Browse the repository at this point in the history
Summary: it's more idiomatic and avoids the second lookup for matching path

Reviewed By: calebho

Differential Revision: D55931716

fbshipit-source-id: ee71b6817c4f77f27994d6f892ea0b732e9f12aa
  • Loading branch information
ttsugriy authored and facebook-github-bot committed Apr 9, 2024
1 parent b8f529e commit 9559f6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions iopath/common/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,9 @@ def __get_path_handler(self, path: Union[str, os.PathLike]) -> PathHandler:
handler (PathHandler)
"""
path = os.fspath(path) # pyre-ignore
for p in self._path_handlers.keys():
for p, handler in self._path_handlers.items():
if path.startswith(p):
return self._path_handlers[p]
return handler
return self._native_path_handler

def __log_tmetry_keys(self, handler: PathHandler, kvs: Dict[str, VTYPE]) -> None:
Expand Down

0 comments on commit 9559f6d

Please sign in to comment.