Skip to content

Conversation

@cachebag
Copy link
Owner

Change decode_ssid_or_empty to return a borrowed slice instead of String

@cachebag cachebag requested a review from Copilot December 25, 2025 04:14
@cachebag cachebag self-assigned this Dec 25, 2025
@cachebag cachebag added enhancement New feature or request core Changes needed for the dbus proxy or general app functions. labels Dec 25, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the decode_ssid_or_empty function by changing its return type from String to Cow<'static, str> to reduce allocations by returning borrowed slices when possible. The function is used for SSID comparison throughout the codebase, and avoiding allocations can improve performance.

  • Changed decode_ssid_or_empty return type from String to Cow<'static, str>
  • Updated call sites to convert Cow to String where needed using .to_string()

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
nmrs/src/util/utils.rs Modified decode_ssid_or_empty to return Cow<'static, str> instead of String, returning Cow::Borrowed("") for empty/invalid cases and Cow::Owned(s.to_owned()) for valid UTF-8
nmrs/src/monitoring/info.rs Updated two call sites to convert the Cow return value to String using .to_string() where String is required by the function signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cachebag cachebag merged commit 65fab0b into master Dec 25, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes needed for the dbus proxy or general app functions. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant