~ubuntu-branches/debian/sid/libxml-twig-perl/sid

« back to all changes in this revision

Viewing changes to speedup

  • Committer: Package Import Robot
  • Author(s): Bart Martens
  • Date: 2014-10-26 12:13:00 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20141026121300-7m01kgqds1xjz53n
Tags: 1:3.48-1
* New upstream release.  Closes: #756059.
* debian/patches/06_spelling.diff: Edited to fit new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
                    ); # _$private is inlined
8
8
my $FORMER    = join( '|', qw( parent prev_sibling next_sibling)); # former_$former is inlined
9
9
my $SET_FIELD = join( '|', qw( first_child next_sibling ent data pctarget comment flushed));
10
 
my $SET_NOT_EMPTY= join( '|', qw( pcdata cdata)); # set the field and mark as not empty
 
10
my $SET_NOT_EMPTY= join( '|', qw( pcdata cdata comment)); # set the field
11
11
 
12
12
# depending on the version of perl use either qr or ""
13
13
print STDERR "perl version is $]\n";
14
14
 
15
 
my $var= '(\$[a-z_]+(?:\[\d\])?)';
 
15
my $var= '(\$[a-z_]+(?:\[\d\])?|\$t(?:wig)?->root|\$t(?:wig)?->twig_current|\$t(?:wig)?->{\'?twig_root\'?}|\$t(?:wig)?->{\'?twig_current\'?})';
16
16
 
17
17
my $set_to = '(?:undef|\$\w+|\$\w+->\{\w+\}|\$\w+->\w+|\$\w+->\w+\([^)]+\))';
18
18
my $elt    = '\$(?:elt|new_elt|child|cdata|ent|_?parent|twig_current|next_sibling|first_child|prev_sibling|last_child|ref|elt->_parent)';
30
30
    if( my( $op, $v, $mv)= m{#\s*(>|<|>=|<=)\s*perl\s*5\.(\d+)(?:\.(\d+))?\s*})
31
31
      { $v= sprintf( "5%03d%03d", $v, $mv || 0);
32
32
        my $comp=  "$version $op $v";
33
 
        if( ! eval $comp) { next; }
 
33
        if( ! eval $comp) { print "#$_"; next; }
 
34
        else              { s{#[^#]*\n}{\n} if m{^=encoding}; }
34
35
      }
35
36
 
36
37
  
39
40
 
40
41
    s/$var->set_gi\(\s*(PCDATA|CDATA|PI|COMMENT|ENT)\s*\)/$1\->{gi}= $gi2index{$2}/;
41
42
 
42
 
    s/$var->del_(twig_current|flushed)/delete $1\->{'$2'}/g;
43
 
    s/$var->set_(twig_current|flushed)/$1\->{'$2'}=1/g;
 
43
    s/$var->del_(twig_current)/delete $1\->{'$2'}/g;
 
44
    s/$var->set_(twig_current)/$1\->{'$2'}=1/g;
 
45
    s/$var->_del_(flushed)/delete $1\->{'$2'}/g;
 
46
    s/$var->_set_(flushed)/$1\->{'$2'}=1/g;
 
47
    s/$var->_(flushed)/$1\->{'$2'}/g;
44
48
 
45
49
    s/$var->set_($SET_FIELD)\(([^)]*)\)/$1\->\{$2\}= $3/g;
46
50
    s/$var->($FIELD)\b(?!\()/$1\->\{$2\}/g;
58
62
 
59
63
    s/$var->append_(pcdata|cdata)\(([^)]*)\)/$1\->\{$2\}.= $3/g;
60
64
    s/$var->set_($SET_NOT_EMPTY)\(([^)]*)\)/$1\->\{$2\}= (delete $1->\{empty\} || 1) && $3/g;
 
65
    s/$var->_set_($SET_NOT_EMPTY)\s*\(([^)]*)\)/$1\->{$2}= $3/g;
61
66
 
62
67
    s/(\$[a-z][a-z_]*(?:\[\d\])?)->gi/\$XML::Twig::index2gi\[$1\->{'gi'}\]/g;
63
68
 
73
78
 
74
79
    s/$var->is_empty/$1\->{'empty'}/g;
75
80
    s/$var->set_empty(?:\(([^)]*)\))?(?!_)/"$1\->{empty}= " . ($2 || 1)/ge;
76
 
    s/$var->set_not_empty/$1\->{empty}=0/g;
 
81
    s/$var->set_not_empty/delete $1\->{empty}/g;
77
82
    #s/$var->set_not_empty/delete $1\->{empty}/g;
78
83
 
79
84
    s/$var->_is_private/( (substr( \$XML::Twig::index2gi\[$1\->{'gi'}\], 0, 1) eq '#') && (substr( \$XML::Twig::index2gi\[$1\->{'gi'}\], 0, 9) ne '#default:') )/g;