Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions codeflash/optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ def get_optimizable_functions(self) -> tuple[dict[Path, list[FunctionToOptimize]
assert self.current_worktree is not None
original_git_root = git_root_dir()
file_to_funcs, count, trace = result

# Resolve roots once to avoid repeated filesystem resolves in the loop
original_root_resolved = original_git_root.resolve()
worktree_resolved = self.current_worktree.resolve()

remapped: dict[Path, list[FunctionToOptimize]] = {}
for file_path, funcs in file_to_funcs.items():
new_path = mirror_path(Path(file_path), original_git_root, self.current_worktree)
remapped[new_path] = [
dataclasses.replace(
func, file_path=mirror_path(func.file_path, original_git_root, self.current_worktree)
)
for func in funcs
]
relative_path = file_path.resolve().relative_to(original_root_resolved)
new_path = worktree_resolved / relative_path
remapped[new_path] = [dataclasses.replace(func, file_path=new_path) for func in funcs]
return remapped, count, trace

return result
Expand Down
Loading