Changeset 2903 for proto/PDF


Ignore:
Timestamp:
Feb 10, 2013, 1:25:26 PM (6 years ago)
Author:
lindanl
Message:

Escape parsing and numeric calculation optimization.

Location:
proto/PDF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_pablo.py

    r2902 r2903  
    196196       
    197197def Parse_Escaped(lex, parity, escape_Callouts, out_Callouts):
    198 
    199         odd = parity.odd
    200         even = parity.even
    201 
    202         start = lex.Backslash &~ pablo.Advance(lex.Backslash)
    203        
    204         even_start = start & even       
    205         even_final = pablo.ScanThru(even_start, lex.Backslash)
    206         escape = even_final & odd
    207         escape_char = even & pablo.SpanUpTo(even_start, even_final)
    208        
    209         odd_start = start & odd
    210         odd_final = pablo.ScanThru(odd_start, lex.Backslash)
    211         escape = escape | (odd_final & even)
    212         escape_char |= (odd & pablo.SpanUpTo(odd_start, odd_final))
    213 
    214         escape_Callouts.UELParen = lex.LParen &~ escape
    215         escape_Callouts.UERParen = lex.RParen &~ escape
    216         escape_Callouts.Nonoct = lex.Nonoct & escape   
    217         escape_Callouts.Oct1 = lex.Oct & escape
    218         escape_Callouts.Oct2 = escape_Callouts.Oct1 & pablo.Lookahead(lex.Oct)
    219         escape_Callouts.Oct1 &= ~escape_Callouts.Oct2
    220         escape_Callouts.Oct3 = escape_Callouts.Oct2 & pablo.Lookahead(lex.Oct, 2)
    221         escape_Callouts.Oct2 &= ~escape_Callouts.Oct3
    222         out_Callouts.delmask = escape_char
     198 
     199        escape_Callouts.UELParen = lex.LParen
     200        escape_Callouts.UERParen = lex.RParen
     201        escape_Callouts.Nonoct = 0
     202        escape_Callouts.Oct1 = 0
     203        escape_Callouts.Oct2 = 0
     204        escape_Callouts.Oct3 = 0
     205        out_Callouts.delmask = 0
     206 
     207        if lex.Backslash:
     208
     209          odd = parity.odd
     210          even = parity.even
     211
     212          start = lex.Backslash &~ pablo.Advance(lex.Backslash)
     213         
     214          even_start = start & even     
     215          even_final = pablo.ScanThru(even_start, lex.Backslash)
     216          escape = even_final & odd
     217          escape_char = even & pablo.SpanUpTo(even_start, even_final)
     218         
     219          odd_start = start & odd
     220          odd_final = pablo.ScanThru(odd_start, lex.Backslash)
     221          escape = escape | (odd_final & even)
     222          escape_char |= (odd & pablo.SpanUpTo(odd_start, odd_final))
     223
     224          escape_Callouts.UELParen = lex.LParen &~ escape
     225          escape_Callouts.UERParen = lex.RParen &~ escape
     226          escape_Callouts.Nonoct = lex.Nonoct & escape 
     227          escape_Callouts.Oct1 = lex.Oct & escape
     228          escape_Callouts.Oct2 = escape_Callouts.Oct1 & pablo.Lookahead(lex.Oct)
     229          escape_Callouts.Oct1 &= ~escape_Callouts.Oct2
     230          escape_Callouts.Oct3 = escape_Callouts.Oct2 & pablo.Lookahead(lex.Oct, 2)
     231          escape_Callouts.Oct2 &= ~escape_Callouts.Oct3
     232          out_Callouts.delmask = escape_char
    223233
    224234#def Parse_CommentsLiteralStrings(lex, escaped_Callouts, marker, comments_Callouts, literalStrings_Callouts) :
  • proto/PDF/cb_template.cpp

    r2902 r2903  
    3737BitBlock EOF_mask = simd<1>::constant<1>();
    3838
     39int pow_ten[8] = {1,10,100,1000,10000,100000,1000000,10000000};
     40
    3941
    4042static inline int Digit_postprocessing(char * source, int pos);
     
    4749void do_process(FILE *infile, FILE *outfile, int filesize);
    4850
    49 #define MAX_NUM 1000
     51#define MAX_NUM 1000000
    5052int numbers[MAX_NUM];
    5153int dec_pl[MAX_NUM];
     
    5658    bool negative= false;
    5759    int num = 0;
    58     int start_pos;
     60    int start_pos = -1;
    5961    if (source[pos] == '-')     {
    6062      pos++;
     
    7577    if (negative) (num) = -(num);
    7678    numbers[num_idx] = num;
    77     dec_pl[num_idx] = pow(10, pos - start_pos);
     79    if(start_pos!=-1)
     80      dec_pl[num_idx] = pow_ten[pos - start_pos];
     81    else
     82      dec_pl[num_idx] = 1;
    7883    num_idx++;
    7984}
     
    322327    PERF_SEC_END(parser_timer, chars_read);
    323328   
    324     fwrite(content_buf, 2, content_buf_ptr-content_buf, outfile);
    325 
    326 }
    327 
     329    fwrite(content_buf, 1, content_buf_ptr-content_buf, outfile);
     330
     331}
     332
Note: See TracChangeset for help on using the changeset viewer.