Skip to content

Commit

Permalink
Simplify with just names()
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalbel committed Oct 22, 2024
1 parent 98f9996 commit c7ae20e
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions crates/ark/src/variables/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,28 +1431,9 @@ impl PositronVariable {
let list = List::new(value.sexp)?;
let n = unsafe { list.len() };

let r_names = unsafe { RObject::new(Rf_getAttrib(value.sexp, R_NamesSymbol)) };
let names = if r_is_null(r_names.sexp) {
vec![None; n]
} else {
let names = unsafe { CharacterVector::new_unchecked(r_names) };
if unsafe { names.len() } != n {
vec![None; n]
} else {
names
.iter()
.map(|v| match v {
None => None,
Some(s) => {
if s.len() == 0 {
None
} else {
Some(s)
}
},
})
.collect()
}
let names = match value.names() {
None => vec![None; n],
Some(names) => names,
};

let variables = list
Expand Down

0 comments on commit c7ae20e

Please sign in to comment.