Skip to content

Commit

Permalink
Remove Resource::expr_to_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Jan 8, 2025
1 parent c5a18c5 commit 58de886
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 144 deletions.
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl FaceState {
}

pub(crate) fn update_interceptors_caches(&self, res: &mut Arc<Resource>) {
if let Ok(expr) = KeyExpr::try_from(res.expr_to_string()) {
if let Ok(expr) = KeyExpr::try_from(res.expr().to_string()) {
if let Some(interceptor) = self.in_interceptors.as_ref() {
let cache = interceptor.compute_keyexpr_cache(&expr);
get_mut_unchecked(
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/interests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub(crate) fn declare_interest(
let wtables = zwrite!(tables_ref.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn declare_subscription(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub(crate) fn declare_queryable(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
16 changes: 6 additions & 10 deletions zenoh/src/net/routing/dispatcher/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ impl Resource {
}
}

pub fn expr_to_string(&self) -> String {
self.expr.clone()
}

pub fn expr(&self) -> &str {
&self.expr
}
Expand Down Expand Up @@ -515,10 +511,10 @@ impl Resource {
ext_nodeid: ext::NodeIdType::DEFAULT,
body: DeclareBody::DeclareKeyExpr(DeclareKeyExpr {
id: expr_id,
wire_expr: nonwild_prefix.expr_to_string().into(),
wire_expr: nonwild_prefix.expr().to_string().into(),
}),
},
nonwild_prefix.expr_to_string(),
nonwild_prefix.expr().to_string(),
));
face.update_interceptors_caches(&mut nonwild_prefix);
WireExpr {
Expand All @@ -527,7 +523,7 @@ impl Resource {
mapping: Mapping::Sender,
}
} else {
res.expr_to_string().into()
res.expr().to_string().into()
}
}
None => wildsuffix.into(),
Expand Down Expand Up @@ -705,7 +701,7 @@ pub(crate) fn register_expr(
{
Some(mut prefix) => match face.remote_mappings.get(&expr_id) {
Some(res) => {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
if res.expr() != fullexpr {
tracing::error!(
Expand All @@ -726,7 +722,7 @@ pub(crate) fn register_expr(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down Expand Up @@ -790,7 +786,7 @@ pub(crate) fn register_expr_interest(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'a> RoutingExpr<'a> {
#[inline]
pub(crate) fn full_expr(&mut self) -> &str {
if self.full.is_none() {
self.full = Some(self.prefix.expr_to_string() + self.suffix);
self.full = Some(self.prefix.expr().to_string() + self.suffix);
}
self.full.as_ref().unwrap()
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh/src/net/routing/dispatcher/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) fn declare_token(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down Expand Up @@ -123,7 +123,7 @@ pub(crate) fn undeclare_token(
None => {
// Here we create a Resource that will immediately be removed after treatment
// TODO this could be improved
let mut fullexpr = prefix.expr_to_string();
let mut fullexpr = prefix.expr().to_string();
fullexpr.push_str(expr.wire_expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/hat/client/interests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(super) fn interests_new_face(tables: &mut Tables, face: &mut Arc<FaceState>)
ext_nodeid: ext::NodeIdType::DEFAULT,
},
res.as_ref()
.map(|res| res.expr_to_string())
.map(|res| res.expr().to_string())
.unwrap_or_default(),
));
}
Expand Down Expand Up @@ -149,7 +149,7 @@ impl HatInterestTrait for HatCode {
ext_nodeid: ext::NodeIdType::DEFAULT,
},
res.as_ref()
.map(|res| res.expr_to_string())
.map(|res| res.expr().to_string())
.unwrap_or_default(),
));
}
Expand Down Expand Up @@ -227,7 +227,7 @@ impl HatInterestTrait for HatCode {
local_interest
.res
.as_ref()
.map(|res| res.expr_to_string())
.map(|res| res.expr().to_string())
.unwrap_or_default(),
));
get_mut_unchecked(dst_face).local_interests.remove(&id);
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/hat/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn propagate_simple_subscription_to(
wire_expr: key_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ fn propagate_forget_simple_subscription(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ pub(super) fn undeclare_simple_subscription(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/hat/client/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn propagate_simple_queryable(
ext_info: info,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ fn propagate_forget_simple_queryable(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -238,7 +238,7 @@ pub(super) fn undeclare_simple_queryable(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down
16 changes: 8 additions & 8 deletions zenoh/src/net/routing/hat/client/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn propagate_simple_token_to(
wire_expr: key_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ fn declare_simple_token(
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
return;
Expand Down Expand Up @@ -185,7 +185,7 @@ fn propagate_forget_simple_token(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
} else if face_hat!(face)
Expand All @@ -210,7 +210,7 @@ fn propagate_forget_simple_token(
},
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -253,7 +253,7 @@ pub(super) fn undeclare_simple_token(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -343,7 +343,7 @@ pub(crate) fn declare_token_interest(
ext_nodeid: ext::NodeIdType::DEFAULT,
body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ pub(crate) fn declare_token_interest(
wire_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
)
}
Expand Down Expand Up @@ -400,7 +400,7 @@ pub(crate) fn declare_token_interest(
ext_nodeid: ext::NodeIdType::DEFAULT,
body: DeclareBody::DeclareToken(DeclareToken { id, wire_expr }),
},
token.expr_to_string(),
token.expr().to_string(),
),
);
}
Expand Down
22 changes: 11 additions & 11 deletions zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn send_sourced_subscription_to_net_children(
wire_expr: key_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
));
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ fn propagate_simple_subscription_to(
wire_expr: key_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
} else {
Expand Down Expand Up @@ -163,7 +163,7 @@ fn propagate_simple_subscription_to(
wire_expr: key_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -371,7 +371,7 @@ fn send_forget_sourced_subscription_to_net_children(
ext_wire_expr: WireExprType { wire_expr },
}),
},
res.expr_to_string(),
res.expr().to_string(),
));
}
}
Expand Down Expand Up @@ -401,7 +401,7 @@ fn propagate_forget_simple_subscription(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -431,7 +431,7 @@ fn propagate_forget_simple_subscription(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -557,7 +557,7 @@ pub(super) fn undeclare_simple_subscription(
ext_wire_expr: WireExprType::null(),
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -590,7 +590,7 @@ pub(super) fn undeclare_simple_subscription(
},
),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand Down Expand Up @@ -724,7 +724,7 @@ pub(super) fn declare_sub_interest(
wire_expr,
}),
},
res.expr_to_string(),
res.expr().to_string(),
),
);
}
Expand All @@ -750,7 +750,7 @@ pub(super) fn declare_sub_interest(
wire_expr,
}),
},
sub.expr_to_string(),
sub.expr().to_string(),
),
);
}
Expand All @@ -776,7 +776,7 @@ pub(super) fn declare_sub_interest(
wire_expr,
}),
},
sub.expr_to_string(),
sub.expr().to_string(),
),
);
}
Expand Down
Loading

0 comments on commit 58de886

Please sign in to comment.