Skip to content

Commit

Permalink
fix logic bug
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Aug 20, 2024
1 parent c402c20 commit 7280fdf
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ where
return Ok(());
}

// Too small to be worth spawning a hashmap for, this is at most 6 comparisons.
if items.len() <= 4 {
// Too small to be worth spawning a hashmap for, this is at most 6 comparisons.
for i in 0..items.len() - 1 {
let name = get_name(&items[i]);
for other in items.iter().skip(i + 1) {
Expand All @@ -80,16 +80,15 @@ where
}
}
}
}

let mut names = PlHashSet::with_capacity(items.len());
for item in items {
let name = get_name(item);
if !names.insert(name) {
polars_bail!(duplicate = name);
} else {
let mut names = PlHashSet::with_capacity(items.len());
for item in items {
let name = get_name(item);
if !names.insert(name) {
polars_bail!(duplicate = name);
}
}
}

Ok(())
}

Expand Down

0 comments on commit 7280fdf

Please sign in to comment.