Commits

Shlomi Fish committed 71edbe9

Convert a call to ->map in void context to foreach.

This:

1. Better conveys the intentions of the code.

2. Might be somewhat faster.

Comments (0)

Files changed (1)

lib/XML/LibXML/NodeList.pm

 sub foreach {
     my $self = CORE::shift;
     my $sub  = CORE::shift;
-    $self->map($sub);
+
+    foreach my $item (@$self)
+    {
+        local $_ = $item;
+        $sub->($item);
+    }
+
     return wantarray ? @$self : $self;
 }