shlomif / perl-XML-LibXML

The XML-LibXML CPAN Distribution for Processing XML using the libxml2 library
https://metacpan.org/release/XML-LibXML
Other
17 stars 35 forks source link

Make parsing of large perl strings much faster. #5

Closed rixed closed 7 years ago

rixed commented 7 years ago

Do not compute the full string length just to find out if the string is empty or not!

This makes parsing of large input strings very slow. For instance, 20 minutes for aqq 12MiB string.

Maybe what caused this (old) bug: https://rt.cpan.org/Public/Bug/Display.html?id=84519

shlomif commented 7 years ago

Thanks, @rixed!

I like the direction of the patch, but there is one problem: the macro is titled "IS_EMPTY()" while it does the opposite. Can you please revise that? I also notice that in all these cases we check for NULL first which is duplicate code and should be extracted into an inline function or a macro. Finally, AppVeyor CI failed (not your fault) so this pull req should be updated.

rixed commented 7 years ago

Regarding the name of the macro, a coworker notified my already of this and I updated the patch.

Regarding the NULL I considered to include it in the macro but I'd prefered to not hide the check. Maybe a poor choice (Unfortunately I haven't written C for a while now and my judgment may not be that good any more :)) WDYT?

shlomif commented 7 years ago

Merged! Thanks!