Fossil

Check-in [f246ea43]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:A little bit faster, by only accessing *z once and using bit-operations in stead of comparisions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | invalid_utf8_table
Files: files | file ages | folders
SHA1: f246ea43130abcd5244754c717cb8127aecfb611
User & Date: jan.nijtmans 2016-06-16 08:04:33
Context
2016-06-16
09:14
Merge trunk check-in: a3328c00 user: jan.nijtmans tags: invalid_utf8_table
08:04
A little bit faster, by only accessing *z once and using bit-operations in stead of comparisions. check-in: f246ea43 user: jan.nijtmans tags: invalid_utf8_table
07:46
Unroll loop for even greater speed check-in: cc09e003 user: jan.nijtmans tags: invalid_utf8_table
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lookslike.c.

217
218
219
220
221
222
223
224

225
226
227
228


229
230
231
232
233
234
235
      /* we already know byte #0 is good, so check the remaining bytes */
      if( (*z<*def++) || (*z++>*def++) ){
        /* if the byte is outside the allowed range for this definition,
         * return invalid */
        return LOOK_INVALID;
      }
      if( len > 2 ){
        if( (*z<0x80) || (*z++>0xBF) ){

          return LOOK_INVALID;
        }
        if( len > 3 ){
          if( (*z<0x80) || (*z++>0xBF) ){


            return LOOK_INVALID;
          }
        }
      }
      /* advance to the next sequence */
      n -= len;
    }







|
>
|


<
>
>







217
218
219
220
221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236
237
      /* we already know byte #0 is good, so check the remaining bytes */
      if( (*z<*def++) || (*z++>*def++) ){
        /* if the byte is outside the allowed range for this definition,
         * return invalid */
        return LOOK_INVALID;
      }
      if( len > 2 ){
        /* if the next byte is not between 0x80 and 0xBF, return invalid */
        if( (*z++&0xC0)!=0x80 ){
           return LOOK_INVALID;
        }
        if( len > 3 ){

          /* if the next byte is not between 0x80 and 0xBF, return invalid */
          if( (*z++&0xC0)!=0x80 ){
            return LOOK_INVALID;
          }
        }
      }
      /* advance to the next sequence */
      n -= len;
    }