1717from codeflash .code_utils .env_utils import get_codeflash_api_key
1818from codeflash .code_utils .git_utils import get_last_commit_author_if_pr_exists , get_repo_owner_and_name
1919from codeflash .code_utils .time_utils import humanize_runtime
20- from codeflash .github .PrComment import FileDiffContent
2120from codeflash .lsp .helpers import is_LSP_enabled
2221from codeflash .models .ExperimentMetadata import ExperimentMetadata
2322from codeflash .models .models import AIServiceRefinerRequest , CodeStringsMarkdown , OptimizedCandidate
@@ -554,7 +553,18 @@ def get_optimization_impact(
554553 - 'high','medium' or 'low' optimization impact
555554
556555 """
557- diff_str = '\n ' .join ([unified_diff_strings (code1 = original_code [p ], code2 = new_code [p ], fromfile = Path (p ).relative_to (root_dir ).as_posix (), tofile = Path (p ).relative_to (root_dir ).as_posix ()) for p in original_code if not is_zero_diff (original_code [p ], new_code [p ])])
556+ diff_str = "\n " .join (
557+ [
558+ unified_diff_strings (
559+ code1 = original_code [p ],
560+ code2 = new_code [p ],
561+ fromfile = Path (p ).relative_to (root_dir ).as_posix (),
562+ tofile = Path (p ).relative_to (root_dir ).as_posix (),
563+ )
564+ for p in original_code
565+ if not is_zero_diff (original_code [p ], new_code [p ])
566+ ]
567+ )
558568 code_diff = f"```diff\n { diff_str } \n ```"
559569 logger .info ("!lsp|Computing Optimization Impact…" )
560570 payload = {
@@ -565,7 +575,7 @@ def get_optimization_impact(
565575 "coverage_message" : coverage_message ,
566576 "replay_tests" : replay_tests ,
567577 "concolic_tests" : concolic_tests ,
568- "speedup" : f"{ 100 + 100 * float (explanation .speedup ):.2f} %" ,
578+ "speedup" : f"{ 100 + 100 * float (explanation .speedup ):.2f} %" ,
569579 "loop_count" : explanation .winning_benchmarking_test_results .number_of_loops (),
570580 "benchmark_details" : explanation .benchmark_details if explanation .benchmark_details else None ,
571581 "optimized_runtime" : humanize_runtime (explanation .best_runtime_ns ),
0 commit comments