Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: do not clone configs Vec for unprocessed imports #262

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions swhkd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ impl Config {

pub fn load_and_merge(config: Self) -> Result<Vec<Self>, Error> {
let mut configs = vec![config];
let mut prev_count = 0;
let mut current_count = configs.len();
while prev_count != current_count {
prev_count = configs.len();
for config in configs.clone() {
for import in Self::load_to_configs(&config)? {
let mut processed = 0;

while processed != configs.len() {
let unprocessed_range = processed..configs.len();
for unprocessed in unprocessed_range {
for import in Self::load_to_configs(&configs[unprocessed])? {
if !configs.contains(&import) {
configs.push(import);
}
}
processed += 1;
}
current_count = configs.len();
}
Ok(configs)
}
Expand Down
Loading