diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-18 01:38:06 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-18 01:38:06 +0900 |
| commit | 4ae58baf8618f5fe916ba2a69faaca93514134ce (patch) | |
| tree | 447e69cea836737db705b357bcc0f85c558062da | |
| parent | 6991ca4c577382651139c70ebfe944eaf959796b (diff) | |
| download | php-shirabe-4ae58baf8618f5fe916ba2a69faaca93514134ce.tar.gz php-shirabe-4ae58baf8618f5fe916ba2a69faaca93514134ce.tar.zst php-shirabe-4ae58baf8618f5fe916ba2a69faaca93514134ce.zip | |
perf(json-file): buffer schema file reads in FileRetriever
serde_json::from_reader issues one read() syscall per byte against an
unbuffered Reader. FileRetriever passed a raw File straight through,
so resolving the composer-schema.json $ref read its ~71KB contents
one byte at a time (twice per require, since schema validation runs
both before and during the update).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| -rw-r--r-- | crates/shirabe/src/json/json_file.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index b95732fa..075e1f64 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -593,7 +593,7 @@ impl jsonschema::Retrieve for FileRetriever { match uri.scheme().as_str() { "file" => { let file = std::fs::File::open(uri.path().as_str())?; - Ok(serde_json::from_reader(file)?) + Ok(serde_json::from_reader(std::io::BufReader::new(file))?) } scheme => Err(format!("Unknown scheme {scheme}").into()), } |
