[PR #17667] Return strings directly from read_file_as_utf8_string_if_exists #31316

Open
opened 2026-01-31 09:46:31 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17667

State: closed
Merged: Yes


  • Every single place that called read_file_as_utf8_string_if_exists
    would immediately do a .value_or(std::string{}).
    As such, the function now returns a string directly.
  • There was just one caller to read_file_as_utf8_string
    and it only cared about files that are non-empty.
    As such, the specialization got removed.

Both of these make sense to me, as in practice there's seldom
a difference between an empty file and a non-existent one.

Validation Steps Performed

  • Compiles ✅
  • Starts ✅
  • Deleting the settings.json contents triggers a reload ✅
**Original Pull Request:** https://github.com/microsoft/terminal/pull/17667 **State:** closed **Merged:** Yes --- * Every single place that called `read_file_as_utf8_string_if_exists` would immediately do a `.value_or(std::string{})`. As such, the function now returns a string directly. * There was just one caller to `read_file_as_utf8_string` and it only cared about files that are non-empty. As such, the specialization got removed. Both of these make sense to me, as in practice there's seldom a difference between an empty file and a non-existent one. ## Validation Steps Performed * Compiles ✅ * Starts ✅ * Deleting the `settings.json` contents triggers a reload ✅
claunia added the pull-request label 2026-01-31 09:46:31 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31316