yamadashy / repopack

📦 Repopack is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, and Gemini.
MIT License
1.51k stars 82 forks source link

Optimize File Manipulation Logic in `fileManipulate.ts` #112

Open Mefisto04 opened 4 days ago

Mefisto04 commented 4 days ago

The current implementation of the file manipulation logic in repopack/src/core/file/fileManipulate.ts can be optimized for performance. Several areas, such as regex handling, string trimming, and quote matching, can be made more efficient.

Proposed Optimizations:

  1. Improve Docstring Removal Regex:
    Simplify and optimize the regex used for removing docstrings in PythonManipulator.

  2. Optimize Quote Matching in removeHashComments:
    Enhance the logic to reduce redundant slice operations and improve performance in detecting quoted strings.

  3. Refactor searchInPairs Binary Search:
    Streamline the binary search function for checking if a hash is inside a string literal.

  4. Enhance rtrimLines Function:
    Use a more efficient method to trim trailing spaces and tabs from lines.

  5. Lazy Instantiate Manipulators:
    Instantiate manipulators in the manipulators object only when needed to improve memory usage.


Expected Benefits:

I'd like to contribute to optimizing the file manipulation logic in fileManipulate.ts as described in the issue. Could you please assign it to me so I can start working on it?

Thanks!

Mefisto04 commented 1 day ago

hey @yamadashy, please go though this issue on your leisure