Skip to content

Commit

Permalink
refactor: Use Arc::clone() instead of .clone()
Browse files Browse the repository at this point in the history
in order to clearly mark that no costly deepcopy is performed.
  • Loading branch information
philipp-caspers committed Jul 30, 2024
1 parent bf8e2c9 commit 595c0ea
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/ros2/simple-publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ fn main() -> Result<(), RclrsError> {
.publish_data(sine.next().unwrap())
.unwrap();
});
rclrs::spin(publisher.node.clone())
rclrs::spin(Arc::clone(&publisher.node))
}
2 changes: 1 addition & 1 deletion examples/ros2/simple-subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ impl Subscriber {
fn main() -> Result<(), RclrsError> {
let subscription =
Arc::new(Subscriber::new("joint_states_subscriber", "joint_states").unwrap());
rclrs::spin(subscription.node.clone())
rclrs::spin(Arc::clone(&subscription.node))
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const FREQUENCY_HZ: u64 = 1000;
fn main() -> Result<(), RclrsError> {
let context = Context::new(env::args()).unwrap();
let node = create_node(&context, "voraus_bridge_node")?;
let node_copy = node.clone();
let node_copy = Arc::clone(&node);
let joint_state_publisher = Arc::new(RosPublisher::new(&node, "joint_states").unwrap());
let publisher_thread_throttle_us =
((1.0 / FREQUENCY_HZ as f64) * 1000.0 * 1000.0).round() as u64;
Expand Down
2 changes: 1 addition & 1 deletion src/simple_opc_ua_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn launch_subscriber() -> Result<(), ()> {
),
IdentityToken::Anonymous,
) {
if let Err(result) = subscribe_to_variables(session.clone(), 2) {
if let Err(result) = subscribe_to_variables(Arc::clone(&session), 2) {
println!(
"ERROR: Got an error while subscribing to variables - {}",
result
Expand Down

0 comments on commit 595c0ea

Please sign in to comment.