Skip to content

Commit

Permalink
fix comment, simplify other cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 12, 2024
1 parent 32df09e commit 603ed76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,9 @@ impl DataFrame {
None => first_len = Some(s.len()),
}

if names.contains(name) {
if !names.insert(name) {
polars_bail!(duplicate = name);
}

names.insert(name);
}
// we drop early as the brchk thinks the &str borrows are used when calling the drop
// of both `series_cols` and `names`
Expand Down Expand Up @@ -402,7 +400,7 @@ impl DataFrame {

/// Create a new `DataFrame` but does not check the length or duplicate occurrence of the `Series`.
///
/// It is advised to use [Series::new](Series::new) in favor of this method.
/// It is advised to use [DataFrame::new](DataFrame::new) in favor of this method.
///
/// # Panic
/// It is the callers responsibility to uphold the contract of all `Series`
Expand All @@ -414,7 +412,7 @@ impl DataFrame {
/// Create a new `DataFrame` but does not check the length of the `Series`,
/// only check for duplicates.
///
/// It is advised to use [Series::new](Series::new) in favor of this method.
/// It is advised to use [DataFrame::new](DataFrame::new) in favor of this method.
///
/// # Panic
/// It is the callers responsibility to uphold the contract of all `Series`
Expand All @@ -424,8 +422,7 @@ impl DataFrame {
for column in &columns {
let name = column.name();
if !names.insert(name) {
// If insertion fails, it means the element is already in the set (duplicate)
polars_bail!(duplicate = name)
polars_bail!(duplicate = name);
}
}
// we drop early as the brchk thinks the &str borrows are used when calling the drop
Expand Down Expand Up @@ -1542,6 +1539,9 @@ impl DataFrame {
polars_bail!(duplicate = name);
}
}
// we drop early as the brchk thinks the &str borrows are used when calling the drop
// of both `series_cols` and `names`
drop(names);
Ok(())
}

Expand Down

0 comments on commit 603ed76

Please sign in to comment.