From c843c8c1e1ef62cceaf71d204f7150c819283102 Mon Sep 17 00:00:00 2001 From: shrutu0929 Date: Tue, 7 Apr 2026 18:22:10 +0530 Subject: [PATCH] perf: Reuse CodeChunker in RAGIndexer._index_file --- refactron/rag/indexer.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/refactron/rag/indexer.py b/refactron/rag/indexer.py index 690cfe3..b375b1a 100644 --- a/refactron/rag/indexer.py +++ b/refactron/rag/indexer.py @@ -89,6 +89,8 @@ def __init__( ) self.parser = CodeParser() + from refactron.rag.chunker import CodeChunker + self.chunker = CodeChunker(self.parser) def index_repository( self, repo_path: Optional[Path] = None, summarize: bool = False @@ -171,11 +173,8 @@ def _index_file(self, file_path: Path, summarize: bool = False) -> List[CodeChun Returns: List of code chunks that were indexed """ - from refactron.rag.chunker import CodeChunker - # Chunk the file (parser is called inside chunker) - chunker = CodeChunker(self.parser) - chunks = chunker.chunk_file(file_path) + chunks = self.chunker.chunk_file(file_path) if summarize and self.llm_client: for chunk in chunks: