Skip to content

Commit ebdf021

Browse files
committed
perf: avoid double dict lookup for line profiler results
1 parent c03b2a2 commit ebdf021

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

codeflash/models/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,9 @@ def handle_duplicate_candidate(
553553
self.optimized_runtimes[candidate.optimization_id] = self.optimized_runtimes.get(past_opt_id)
554554

555555
# Line profiler results only available for successful runs
556-
if past_opt_id in self.optimized_line_profiler_results:
557-
self.optimized_line_profiler_results[candidate.optimization_id] = self.optimized_line_profiler_results[
558-
past_opt_id
559-
]
556+
line_profiler_result = self.optimized_line_profiler_results.get(past_opt_id)
557+
if line_profiler_result is not None:
558+
self.optimized_line_profiler_results[candidate.optimization_id] = line_profiler_result
560559

561560
self.optimizations_post[candidate.optimization_id] = self.ast_code_to_id[normalized_code][
562561
"shorter_source_code"

0 commit comments

Comments
 (0)