-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unneeded clone #94
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,7 +258,6 @@ extern "C" fn init(callbacks: *mut PluginCallbacks, config_path: *const c_char) | |
match unsafe { callbacks.as_ref() } { | ||
Some(c) => { | ||
unsafe { CALLBACKS = Some(c) }; | ||
let mut senders = Vec::new(); | ||
let num_threads = if message_threads == 0 { | ||
let cpus = num_cpus::get(); | ||
janus_info!("message_threads is set to 0, setting it to {} (number of cpus)", cpus); | ||
|
@@ -267,9 +266,10 @@ extern "C" fn init(callbacks: *mut PluginCallbacks, config_path: *const c_char) | |
message_threads | ||
}; | ||
|
||
let mut senders = Vec::with_capacity(num_threads); | ||
for i in 0..num_threads { | ||
let (messages_tx, messages_rx) = mpsc::sync_channel(0); | ||
senders.push(messages_tx.clone()); | ||
senders.push(messages_tx); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
thread::Builder::new() | ||
.name(format!("sfu msg {}", i)) | ||
|
@@ -479,7 +479,7 @@ fn process_join(from: &Arc<Session>, room_id: RoomId, user_id: UserId, subscribe | |
switchboard.join_publisher(Arc::clone(from), user_id.clone(), room_id.clone()); | ||
notify_except(¬ification, &user_id, switchboard.publishers_occupying(&room_id)); | ||
} else { | ||
switchboard.join_subscriber(Arc::clone(from), user_id.clone(), room_id.clone()); | ||
switchboard.join_subscriber(Arc::clone(from), user_id, room_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If found this one with Note that in |
||
} | ||
|
||
if let Some(subscription) = subscribe { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating
Vec
withVec::with_capacity
is a best practice when you know the size in advance.From memory allocation point of view, I read there is no allocation when using
Vec::new
, there is an allocation for 4 items on the first push, then a new allocation with capacity x2 when the capacity is reached and so on.Here nothing changes fundamentally, this code is executed when the plugin initialize, we may save an extra allocation if you have more than 4 cpus. :)