Skip to content

Commit 23057ef

Browse files
authored
Merge pull request #313 from uklotzde/clippy_clone_on_ref_ptr
Use unified function syntax for ref-counted types
2 parents f4722e7 + 7fce89a commit 23057ef

File tree

15 files changed

+34
-32
lines changed

15 files changed

+34
-32
lines changed

examples/roundtrip_latency_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl LatencyTesterNode {
105105
let estimated_latency = Arc::new(AtomicF64::new(0.));
106106

107107
let render = LatencyTesterProcessor {
108-
estimated_latency: estimated_latency.clone(),
108+
estimated_latency: Arc::clone(&estimated_latency),
109109
send_time: 0.,
110110
};
111111

src/context/offline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl OfflineAudioContext {
7373

7474
// track number of frames - synced from render thread to control thread
7575
let frames_played = Arc::new(AtomicU64::new(0));
76-
let frames_played_clone = frames_played.clone();
76+
let frames_played_clone = Arc::clone(&frames_played);
7777

7878
// setup the render 'thread', which will run inside the control thread
7979
let renderer = RenderThread::new(

src/io/cpal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl AudioBackendManager for CpalBackend {
175175
sample_rate,
176176
preferred.channels as usize,
177177
ctrl_msg_recv.clone(),
178-
frames_played.clone(),
178+
Arc::clone(&frames_played),
179179
Some(load_value_send.clone()),
180180
Some(event_send.clone()),
181181
);
@@ -189,7 +189,7 @@ impl AudioBackendManager for CpalBackend {
189189
supported.sample_format(),
190190
&preferred,
191191
renderer,
192-
output_latency.clone(),
192+
Arc::clone(&output_latency),
193193
);
194194

195195
let stream = match spawned {
@@ -223,7 +223,7 @@ impl AudioBackendManager for CpalBackend {
223223
supported.sample_format(),
224224
&supported_config,
225225
renderer,
226-
output_latency.clone(),
226+
Arc::clone(&output_latency),
227227
);
228228
spawned.expect("OutputStream build failed with default config")
229229
}

src/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn thread_init() -> (ControlThreadInit, RenderThreadInit) {
6161
let (event_send, event_recv) = crossbeam_channel::bounded(256);
6262

6363
let control_thread_init = ControlThreadInit {
64-
frames_played: frames_played.clone(),
64+
frames_played: Arc::clone(&frames_played),
6565
ctrl_msg_send,
6666
load_value_recv,
6767
event_send: event_send.clone(),

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![warn(rust_2018_idioms)]
3838
#![warn(rust_2021_compatibility)]
3939
#![warn(clippy::missing_panics_doc)]
40+
#![warn(clippy::clone_on_ref_ptr)]
4041
#![deny(trivial_numeric_casts)]
4142

4243
use std::error::Error;

src/media_element.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ impl MediaElement {
7979

8080
let rts_stream = RTSStream {
8181
stream: read_disk_stream,
82-
current_time: current_time.clone(),
82+
current_time: Arc::clone(&current_time),
8383
receiver,
84-
loop_: loop_.clone(),
85-
paused: paused.clone(),
86-
playback_rate: playback_rate.clone(),
84+
loop_: Arc::clone(&loop_),
85+
paused: Arc::clone(&paused),
86+
playback_rate: Arc::clone(&playback_rate),
8787
};
8888

8989
Ok(Self {

src/media_recorder/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl MediaRecorder {
208208
panic!("InvalidStateError: recorder has already started")
209209
}
210210

211-
let inner = self.inner.clone();
211+
let inner = Arc::clone(&self.inner);
212212
let blob = Vec::with_capacity(128 * 1024);
213213

214214
std::thread::spawn(move || {
@@ -290,7 +290,7 @@ mod tests {
290290
let recorder = MediaRecorder::new(&stream);
291291

292292
{
293-
let data_received = data_received.clone();
293+
let data_received = Arc::clone(&data_received);
294294
recorder.set_ondataavailable(move |_| data_received.store(true, Ordering::Relaxed));
295295
}
296296

@@ -321,11 +321,11 @@ mod tests {
321321
let recorder = MediaRecorder::new(&stream);
322322

323323
{
324-
let data_received = data_received.clone();
324+
let data_received = Arc::clone(&data_received);
325325
recorder.set_ondataavailable(move |_| data_received.store(true, Ordering::Relaxed));
326326
}
327327
{
328-
let error_received = error_received.clone();
328+
let error_received = Arc::clone(&error_received);
329329
recorder.set_onerror(move |_| error_received.store(true, Ordering::Relaxed));
330330
}
331331

@@ -354,7 +354,7 @@ mod tests {
354354

355355
let samples: Arc<Mutex<Vec<u8>>> = Default::default();
356356
{
357-
let samples = samples.clone();
357+
let samples = Arc::clone(&samples);
358358
recorder.set_ondataavailable(move |e| {
359359
samples.lock().unwrap().extend_from_slice(&e.blob);
360360
});

src/media_streams/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl MediaStreamTrack {
6767

6868
pub fn iter(&self) -> impl Iterator<Item = FallibleBuffer> {
6969
MediaStreamTrackIter {
70-
track: self.inner.clone(),
70+
track: Arc::clone(&self.inner),
7171
position: 0,
7272
}
7373
}

src/node/biquad_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl BiquadFilterNode {
384384
detune: d_proc,
385385
frequency: f_proc,
386386
q: q_proc,
387-
type_: type_.clone(),
387+
type_: Arc::clone(&type_),
388388
x1: Vec::with_capacity(MAX_CHANNELS),
389389
x2: Vec::with_capacity(MAX_CHANNELS),
390390
y1: Vec::with_capacity(MAX_CHANNELS),

src/node/delay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ impl DelayNode {
206206
let ring_buffer = Vec::with_capacity(num_quanta);
207207

208208
let shared_ring_buffer = Rc::new(RefCell::new(ring_buffer));
209-
let shared_ring_buffer_clone = shared_ring_buffer.clone();
209+
let shared_ring_buffer_clone = Rc::clone(&shared_ring_buffer);
210210

211211
// shared value set by the writer when it is dropped
212212
let last_written_index = Rc::new(Cell::<Option<usize>>::new(None));
213-
let last_written_index_clone = last_written_index.clone();
213+
let last_written_index_clone = Rc::clone(&last_written_index);
214214

215215
// shared value for reader/writer to determine who was rendered first,
216216
// this will indicate if the delay node acts as a cycle breaker
217217
let latest_frame_written = Rc::new(AtomicU64::new(u64::MAX));
218-
let latest_frame_written_clone = latest_frame_written.clone();
218+
let latest_frame_written_clone = Rc::clone(&latest_frame_written);
219219

220220
let node = context.register(move |writer_registration| {
221221
let node = context.register(move |reader_registration| {

0 commit comments

Comments
 (0)