mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Skip an extra trip through filesystem on the critical path
This commit is contained in:
parent
d2d7bad04a
commit
78a11a27b6
@ -6,7 +6,7 @@ mod bytecode;
|
|||||||
use crate::buffer::{InputBuffer, OutputBuffer};
|
use crate::buffer::{InputBuffer, OutputBuffer};
|
||||||
use crate::bytecode::Bytecode;
|
use crate::bytecode::Bytecode;
|
||||||
use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
|
use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
|
||||||
use std::io::{Read, Write};
|
use std::io::{ErrorKind, Read, Write};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{Command, ExitStatus, Stdio};
|
use std::process::{Command, ExitStatus, Stdio};
|
||||||
@ -36,17 +36,23 @@ fn derive(select: u8, input: TokenStream) -> TokenStream {
|
|||||||
env!("CARGO_MANIFEST_DIR"),
|
env!("CARGO_MANIFEST_DIR"),
|
||||||
"/serde_derive-x86_64-unknown-linux-gnu",
|
"/serde_derive-x86_64-unknown-linux-gnu",
|
||||||
));
|
));
|
||||||
if !exe_path.exists() {
|
let mut child = match Command::new(exe_path)
|
||||||
panic!(
|
|
||||||
"file missing from serde_derive manifest directory during macro expansion: {}",
|
|
||||||
exe_path.display(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let mut child = Command::new(exe_path)
|
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to spawn process");
|
{
|
||||||
|
Ok(child) => child,
|
||||||
|
Err(io_error) => {
|
||||||
|
if io_error.kind() == ErrorKind::NotFound {
|
||||||
|
panic!(
|
||||||
|
"file missing from serde_derive manifest directory during macro expansion: {}",
|
||||||
|
exe_path.display(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
panic!("failed to spawn process: {}", io_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut stdin = child.stdin.take().unwrap();
|
let mut stdin = child.stdin.take().unwrap();
|
||||||
let mut buf = buf.into_bytes();
|
let mut buf = buf.into_bytes();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user