1. Toby Inkster
  2. p5-xml-libxml

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.

  • Participants
  • Parent commits e91d5ec
  • Branches default

Comments (0)

Files changed (1)

File lib/XML/LibXML/NodeList.pm

View file
  • Ignore whitespace
 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;
 }