From 1d834c23933800db72cdf0665efda4c7f1d9e99e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 5 Dec 2025 20:52:33 +0100 Subject: [PATCH] init: Read config files all at once This is simpler than streaming and likely a bit faster. Config files are expected to be tiny. --- init/src/main.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/init/src/main.rs b/init/src/main.rs index 086b3e4fe7..8a348f235a 100644 --- a/init/src/main.rs +++ b/init/src/main.rs @@ -1,9 +1,9 @@ use std::collections::BTreeMap; -use std::env; -use std::fs::{read_dir, File}; -use std::io::{BufRead, BufReader, Result}; +use std::fs::read_dir; +use std::io::Result; use std::path::Path; use std::process::Command; +use std::{env, fs}; use libredox::flag::{O_RDONLY, O_WRONLY}; @@ -20,10 +20,7 @@ fn switch_stdio(stdio: &str) -> Result<()> { } pub fn run(file: &Path) -> Result<()> { - let file = File::open(file)?; - let reader = BufReader::new(file); - for line_res in reader.lines() { - let line_raw = line_res?; + for line_raw in fs::read_to_string(file)?.lines() { let line = line_raw.trim(); if !line.is_empty() && !line.starts_with('#') { let mut args = line.split(' ').map(|arg| {