aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_srv/src
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-03-23 19:47:08 +0000
committerEdwin Cheng <[email protected]>2021-03-23 19:51:06 +0000
commit79f583ed6622be591886f99974766a3aeda39182 (patch)
treea332596cd744a1d50b474b5a82d66af171048707 /crates/proc_macro_srv/src
parentf41ae64722ab8e501e2123018d1b0101db32442e (diff)
Improve message usage in proc-macro
Reuse storage for the buffer send to child process of proc-macro.
Diffstat (limited to 'crates/proc_macro_srv/src')
-rw-r--r--crates/proc_macro_srv/src/cli.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/proc_macro_srv/src/cli.rs b/crates/proc_macro_srv/src/cli.rs
index d428b9567..bc48f1c43 100644
--- a/crates/proc_macro_srv/src/cli.rs
+++ b/crates/proc_macro_srv/src/cli.rs
@@ -6,8 +6,9 @@ use std::io;
6 6
7pub fn run() -> io::Result<()> { 7pub fn run() -> io::Result<()> {
8 let mut srv = ProcMacroSrv::default(); 8 let mut srv = ProcMacroSrv::default();
9 let mut buf = String::new();
9 10
10 while let Some(req) = read_request()? { 11 while let Some(req) = read_request(&mut buf)? {
11 let res = match req { 12 let res = match req {
12 msg::Request::ListMacro(task) => srv.list_macros(&task).map(msg::Response::ListMacro), 13 msg::Request::ListMacro(task) => srv.list_macros(&task).map(msg::Response::ListMacro),
13 msg::Request::ExpansionMacro(task) => { 14 msg::Request::ExpansionMacro(task) => {
@@ -30,8 +31,8 @@ pub fn run() -> io::Result<()> {
30 Ok(()) 31 Ok(())
31} 32}
32 33
33fn read_request() -> io::Result<Option<msg::Request>> { 34fn read_request(buf: &mut String) -> io::Result<Option<msg::Request>> {
34 msg::Request::read(&mut io::stdin().lock()) 35 msg::Request::read(&mut io::stdin().lock(), buf)
35} 36}
36 37
37fn write_response(msg: msg::Response) -> io::Result<()> { 38fn write_response(msg: msg::Response) -> io::Result<()> {