Skip to content

Commit 58e4bdb

Browse files
committed
Remove enumeration support from map
1 parent 74fce3f commit 58e4bdb

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

src/eval/array.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,9 @@ impl Array {
181181

182182
/// Transform each item in the array with a function.
183183
pub fn map(&self, vm: &mut Vm, func: Func) -> SourceResult<Self> {
184-
let enumerate = func.argc() == Some(2);
185184
self.iter()
186-
.enumerate()
187-
.map(|(i, item)| {
188-
let mut args = Args::new(func.span(), []);
189-
if enumerate {
190-
args.push(func.span(), Value::Int(i as i64));
191-
}
192-
args.push(func.span(), item.clone());
185+
.map(|item| {
186+
let args = Args::new(func.span(), [item.clone()]);
193187
func.call_vm(vm, args)
194188
})
195189
.collect()

src/eval/func.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ impl Func {
7373
self
7474
}
7575

76-
/// The number of positional arguments this function takes, if known.
77-
pub fn argc(&self) -> Option<usize> {
78-
match &self.repr {
79-
Repr::Closure(closure) => closure.argc(),
80-
Repr::With(arc) => Some(arc.0.argc()?.saturating_sub(
81-
arc.1.items.iter().filter(|arg| arg.name.is_none()).count(),
82-
)),
83-
_ => None,
84-
}
85-
}
86-
8776
/// Call the function with the given arguments.
8877
pub fn call_vm(&self, vm: &mut Vm, mut args: Args) -> SourceResult<Value> {
8978
match &self.repr {
@@ -346,15 +335,6 @@ impl Closure {
346335

347336
result
348337
}
349-
350-
/// The number of positional arguments this closure takes, if known.
351-
fn argc(&self) -> Option<usize> {
352-
if self.sink.is_some() {
353-
return None;
354-
}
355-
356-
Some(self.params.iter().filter(|(_, default)| default.is_none()).count())
357-
}
358338
}
359339

360340
impl From<Closure> for Func {

0 commit comments

Comments
 (0)