Skip to content

Commit a24a161

Browse files
afnanenayetautozimu
authored andcommitted
Refactor code to use references (#790)
Use references instead of copying in functions that don't consume a value
1 parent dce2a8e commit a24a161

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/rpcclient.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl RpcClient {
3131
thread::Builder::new()
3232
.name(reader_thread_name.clone())
3333
.spawn(move || {
34-
if let Err(err) = loop_read(reader, reader_rx, sink, languageId_clone) {
34+
if let Err(err) = loop_read(reader, reader_rx, &sink, &languageId_clone) {
3535
error!("Thread {} exited with error: {:?}", reader_thread_name, err);
3636
}
3737
})?;
@@ -42,7 +42,7 @@ impl RpcClient {
4242
thread::Builder::new()
4343
.name(writer_thread_name.clone())
4444
.spawn(move || {
45-
if let Err(err) = loop_write(writer, writer_rx, languageId_clone) {
45+
if let Err(err) = loop_write(writer, &writer_rx, &languageId_clone) {
4646
error!("Thread {} exited with error: {:?}", writer_thread_name, err);
4747
}
4848
})?;
@@ -120,8 +120,8 @@ impl RpcClient {
120120
fn loop_read(
121121
reader: impl BufRead,
122122
reader_rx: Receiver<(Id, Sender<rpc::Output>)>,
123-
sink: Sender<Call>,
124-
languageId: LanguageId,
123+
sink: &Sender<Call>,
124+
languageId: &LanguageId,
125125
) -> Fallible<()> {
126126
let mut pending_outputs = HashMap::new();
127127

@@ -205,8 +205,8 @@ fn loop_read(
205205

206206
fn loop_write(
207207
writer: impl Write,
208-
rx: Receiver<RawMessage>,
209-
languageId: LanguageId,
208+
rx: &Receiver<RawMessage>,
209+
languageId: &LanguageId,
210210
) -> Fallible<()> {
211211
let mut writer = writer;
212212

0 commit comments

Comments
 (0)