Skip to content

Commit 89271d5

Browse files
committed
perf: use orjson for loading the cache files
1 parent 42eab31 commit 89271d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

refresh.template.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,11 @@ def _get_headers(compile_action, source_path: str):
507507
cache_last_modified = os.path.getmtime(cache_file_path) # Do before opening just as a basic hedge against concurrent write, even though we won't handle the concurrent delete case perfectly.
508508
try:
509509
with open(cache_file_path) as cache_file:
510-
action_key, headers = json.load(cache_file)
510+
try:
511+
from orjson import loads
512+
action_key, headers = loads(cache_file.read())
513+
except ImportError:
514+
action_key, headers = json.load(cache_file)
511515
except json.JSONDecodeError:
512516
# Corrupted cache, which can happen if, for example, the user kills the program, since writes aren't atomic.
513517
# But if it is the result of a bug, we want to print it before it's overwritten, so it can be reported

0 commit comments

Comments
 (0)