Changeset 580


Ignore:
Timestamp:
Aug 18, 2010, 1:37:25 PM (9 years ago)
Author:
lindanl
Message:

boolean does_match function instead of cal_match_len

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/src/tag_matcher.cpp

    r579 r580  
    2828  int tag_match(int pos);
    2929  void Advance_buffer();
    30   int calc_match_len(char * s1, char * s2, int lgth);
     30  int does_match(char * s1, char * s2, int lgth);
    3131};
    3232
    33 int tag_matcher::calc_match_len(char * s1, char * s2, int lgth){
     33int tag_matcher::does_match(char * s1, char * s2, int lgth){
    3434    int matchlen = 0;
    3535    int i=0;
     
    3838      if (simd_all_eq_8(sisd_load_unaligned((SIMD_type*)&s1[i]), sisd_load_unaligned((SIMD_type*)&s2[i]))) {
    3939        lgth -= sizeof(SIMD_type);
    40         matchlen += sizeof(SIMD_type);
    4140        i +=sizeof(SIMD_type);
    4241      }
    4342      else {
    44         return -1;
     43        return 0;
    4544      }
    4645    }
    47     matchlen += cfzl(~_mm_movemask_epi8(simd_eq_8(sisd_load_unaligned((SIMD_type*)&s1[i]), sisd_load_unaligned((SIMD_type*)&s2[i])))); 
    48     return matchlen;
     46    if (lgth > cfzl(~_mm_movemask_epi8(simd_eq_8(sisd_load_unaligned((SIMD_type*)&s1[i]),
     47                                                  sisd_load_unaligned((SIMD_type*)&s2[i])))))
     48      return 0;
     49    else return 1;
    4950}
     51
    5052
    5153int tag_matcher:: tag_match(int pos) {
     
    5658          if (depth<0)
    5759            return pos;
    58           int matchlen = calc_match_len(tag_stack[depth],&srcbuf[pos],tag_lgth_stack[depth]);
    59           if (matchlen > tag_lgth_stack[depth]) return 0;
    60           else if ((matchlen == tag_lgth_stack[depth]) && ((srcbuf[pos+matchlen] == '>') ||(srcbuf[pos+matchlen] <= ' '))) return 0;
    61           else if (pos + matchlen >= BUFFER_SIZE + OVERLAP_BUFSIZE) {
     60          int lgth = tag_lgth_stack[depth];
     61
     62          if (does_match(tag_stack[depth],&srcbuf[pos],lgth) && ((srcbuf[pos+lgth] == '>') ||(srcbuf[pos+lgth] <= ' '))) return 0;
     63          else if (pos + lgth >= BUFFER_SIZE + OVERLAP_BUFSIZE) {
    6264            state = InEndTag;
    6365            inTagPos = BUFFER_SIZE - pos;
     
    129131    }
    130132    else if (state == InEndTag) {
    131       int matchlen = calc_match_len(tag_stack[depth]+inTagPos,srcbuf,tag_lgth_stack[depth]-inTagPos);
    132133      state = Clear;
    133       if (matchlen > tag_lgth_stack[depth]) return ;
    134       else if ((matchlen == tag_lgth_stack[depth]) && ((srcbuf[matchlen] == '>') ||(srcbuf[matchlen] <= ' '))) return;
     134      int lgth = tag_lgth_stack[depth];
     135      if (does_match(tag_stack[depth]+inTagPos,srcbuf,lgth-inTagPos) && ((srcbuf[lgth] == '>') ||(srcbuf[lgth] <= ' '))) return ;       
    135136      else {
    136137          fprintf(stderr,"tag name mismatch at position = %i\n",buf_base);
    137138          exit(-1);
    138       }
     139      }     
    139140    }
    140141  } 
Note: See TracChangeset for help on using the changeset viewer.