Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: XML::Parser ( or Perl internals ) speed mysticism

by sfink (Deacon)
on Mar 26, 2006 at 05:46 UTC ( [id://539264]=note: print w/replies, xml ) Need Help??


in reply to XML::Parser ( or Perl internals ) speed mysticism

With the line commented out, the previous line (the concatenation) is used as the return value of the handler. That return value is passed around and used for who knows what. It gets very large. If you replace the commented out line with "1;", it will be even faster.

It sure is surprising until you figure out what's going on, though!

Replies are listed 'Best First'.
Re^2: XML::Parser ( or Perl internals ) speed mysticism
by zagzag (Novice) on Mar 26, 2006 at 07:55 UTC
    sfink, your right ! This code working fine !
    #!/usr/bin/perl use XML::Parser; our $str; my @arr; my $file = shift; my $parser = new XML::Parser:: Handlers =>{ Char => sub { $str .= $_[1]; return; #clear return value } } ; $parser->parsefile($file);
      sfink, your right ! This code working fine !
      The original code should work fine as well (you've found a bug :)). Since the return value isn't being used for anything, that callback (among others) should be called in void context. The patch is easy, modify Expat.xs, and replace all instances of
      G_DISCARD);
      with
      G_DISCARD|G_VOID);
      I've tested this, and it doesn't seem break anything.

      I've also filed a bug report.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://539264]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (9)
As of 2024-03-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found