microsoft / microsoft/terminal
Clean up CreateFile loop in ReadUTF8File
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
ReadUTF8File in the Settings library tries three times to read the settings file. If the size changes while it is being read, it'll try again.
Right now, the code looks like this (roughly):
while(tries) {
open
check permissions
read in full
check read size
}
It's expensive to open the file and check the permissions every time. Instead, we could:
open
check permissions
while (tries) {
reset file pointer
read in full
check read size
}
That'll save us closing/reopening the file up to three times.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate ReadUTF8File in the Settings library and inspect its current retry loop. Confirm how the file pointer is reset and how permissions and read size are checked; done means the file is opened and permissions are checked once while retries reuse the open file without changing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100