Skip to content

Commit

Permalink
Improve Get call performance by replacing regex with glob matching li…
Browse files Browse the repository at this point in the history
…b for wildcard handling
  • Loading branch information
rafaeling committed Jun 6, 2024
1 parent 82513ea commit bb13826
Show file tree
Hide file tree
Showing 6 changed files with 1,679 additions and 68 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions databroker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
jsonwebtoken = "9.1.0"
regex = "1.7.1"
glob-match = "0.2.1"

jemallocator = { version = "0.5.0", optional = true }
lazy_static = "1.4.0"
Expand Down
6 changes: 4 additions & 2 deletions databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum RegistrationError {
pub struct Metadata {
pub id: i32,
pub path: String,
pub glob_path: String,
pub data_type: DataType,
pub entry_type: EntryType,
pub change_type: ChangeType,
Expand Down Expand Up @@ -726,7 +727,7 @@ impl ChangeSubscription {
notify_fields.insert(Field::ActuatorTarget);
}
// fill unit field always
update.unit = entry.metadata.unit.clone();
update.unit.clone_from(&entry.metadata.unit);
notifications.updates.push(ChangeNotification {
update,
fields: notify_fields,
Expand Down Expand Up @@ -1155,6 +1156,7 @@ impl<'a, 'b> DatabaseWriteAccess<'a, 'b> {
metadata: Metadata {
id: temp_id,
path: name.clone(),
glob_path: name.replace('.', "/"),
data_type,
change_type,
entry_type,
Expand Down Expand Up @@ -1431,7 +1433,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
{
Ok(None) => false,
Ok(Some(lag_updates_)) => {
lag_updates = lag_updates_.clone();
lag_updates.clone_from(&lag_updates_);
false
}
Err(_) => true, // Cleanup needed
Expand Down
Loading

0 comments on commit bb13826

Please sign in to comment.