Skip to content

Conversation

@nots1dd
Copy link
Contributor

@nots1dd nots1dd commented Mar 22, 2025

This commit makes environ.rs more optimized by removing redundant
.to_string() allocations by using borrow::Cow (copy-on-write).

  1. Used filter_map for single pass instead of manual iteration through
    env.lines()

  2. Replace most .to_string() with Cow to remove unnecessary string
    allocations

  3. In construct function, used env::vars.collect() to get all values
    in one pass instead of allocation new string, also now returns env::vars
    by default instead of an empty HashMap<String, String>.

  4. Add some comments for more readability.

This PR was tested with:

make check
make test

I did not create any new functions so NO tests were added or modified.

nots1dd and others added 3 commits March 20, 2025 14:21
1. Used HashSet<Modifier> instead of Vec for faster checks
2. Removed unnecessary .clone() calls
3. Replaced manual iterations over modifiers with HashSet ordered
comparisons.
4. Instead of looping manually to unbind, use .extend()
5. Modified the test to account for the changes above
This commit makes `environ.rs` more optimized by removing redundant
`.to_string()` allocations by using Cow (copy-on-write).

1. Used filter_map for single pass instead of manual iteration through
env.lines()
2. Replace most .to_string() with Cow to remove unnecessary string
allocations
3. In `construct` function, used `env::vars.collect()` to get all values
in one pass instead of allocation new string, also now returns env::vars
by default instead of an empty HashMap<String, String>
@nots1dd
Copy link
Contributor Author

nots1dd commented Mar 22, 2025

Ah maybe should have created a new fork

Copy link
Member

@Shinyzenith Shinyzenith left a comment

Choose a reason for hiding this comment

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

Looks mostly fine to me. @newtoallofthis123 can you check once too.

@Shinyzenith Shinyzenith merged commit e972f55 into waycrate:main Mar 25, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants