constructor inlining

migrate
prplV 2025-05-28 16:42:50 +03:00
parent 3147c73006
commit ac0c3cb8c1
3 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,7 @@
} }
impl FilesController { impl FilesController {
#[inline(always)]
pub fn new(name: &str, triggers: EventHandlers) -> FilesController { pub fn new(name: &str, triggers: EventHandlers) -> FilesController {
let name: Arc<str> = Arc::from(name); let name: Arc<str> = Arc::from(name);
Self { Self {
@ -53,6 +54,7 @@
code_name : name.clone(), code_name : name.clone(),
} }
} }
#[inline(always)]
pub fn with_path(mut self, path: impl AsRef<Path>) -> anyhow::Result<FilesController> { pub fn with_path(mut self, path: impl AsRef<Path>) -> anyhow::Result<FilesController> {
self.path = path.as_ref().to_string_lossy().into_owned(); self.path = path.as_ref().to_string_lossy().into_owned();
self.watcher = { self.watcher = {

View File

@ -61,6 +61,7 @@ pub mod v2 {
} }
impl ProcessesController { impl ProcessesController {
#[inline(always)]
pub fn new(name: &str, event_reader: MpscReciever<Events>) -> ProcessesController { pub fn new(name: &str, event_reader: MpscReciever<Events>) -> ProcessesController {
ProcessesController { ProcessesController {
name : Arc::from(name), name : Arc::from(name),
@ -71,11 +72,11 @@ pub mod v2 {
negative_events : HashSet::new(), negative_events : HashSet::new(),
} }
} }
#[inline(always)]
pub fn with_exe(mut self, bin: impl AsRef<Path>) -> ProcessesController { pub fn with_exe(mut self, bin: impl AsRef<Path>) -> ProcessesController {
self.bin = bin.as_ref().to_string_lossy().into_owned(); self.bin = bin.as_ref().to_string_lossy().into_owned();
self self
} }
pub fn get_pid(&self) -> Pid { pub fn get_pid(&self) -> Pid {
self.pid self.pid
} }

View File

@ -42,6 +42,7 @@ pub mod v2 {
} }
impl ServicesController { impl ServicesController {
#[inline(always)]
pub fn new() -> ServicesController { pub fn new() -> ServicesController {
ServicesController { ServicesController {
name : String::new(), name : String::new(),
@ -51,6 +52,7 @@ pub mod v2 {
event_registrator : EventHandlers::new(), event_registrator : EventHandlers::new(),
} }
} }
#[inline(always)]
pub fn with_access_name( pub fn with_access_name(
mut self, mut self,
hostname: &str, hostname: &str,
@ -60,7 +62,7 @@ pub mod v2 {
self.access_url = Arc::from(access_url); self.access_url = Arc::from(access_url);
self self
} }
#[inline(always)]
pub fn with_params( pub fn with_params(
mut self, mut self,
conn_queue: ConnectionQueue, conn_queue: ConnectionQueue,
@ -70,7 +72,6 @@ pub mod v2 {
self.event_registrator = event_reg; self.event_registrator = event_reg;
self self
} }
pub fn get_access_url(hostname: &str, port: Option<&u32>) -> String { pub fn get_access_url(hostname: &str, port: Option<&u32>) -> String {
format!("{}{}", hostname, port.map_or_else(|| "".to_string(), |p| format!(":{}", p))) format!("{}{}", hostname, port.map_or_else(|| "".to_string(), |p| format!(":{}", p)))
} }