template icon indicating copy to clipboard operation
template copied to clipboard

Streaming file content

Open caffeine-addictt opened this issue 1 year ago • 0 comments

Enhancement Request

Your issue may already be reported! Please check out our active issues before creating one.

Is Your Enhancement Request Related to an Issue?

At present, we load all file contents into memory and do a singular RegExp match and replace operation. Doing it this way is not optimal (not too impactful, but we strive to ship good software c;);

  • Will require more memory
  • Will impact runtime performance

Describe the Solution You'd Like

File streaming.

Instead of loading the file contents into memory, we can just;

  1. stream each line of the file into memory
  2. format the line with the same RegExp
  3. stream the formatted line into a generated file in a generated temp directory
  4. then replace the original file with the formatted file

[!NOTE] I have already tried to implement this, albeit unsuccessfully. You can find my unsuccessful code highlighted here.

Additional Context

PRs welcome!

caffeine-addictt avatar May 02 '24 11:05 caffeine-addictt