Fossil

Check-in [c550d6e0]
Login

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

Overview
Comment:Use strspn() to improve the performance of validate16().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c550d6e0215e33e5e42916aebb742e837c41d311c09247dbacafb14cad9244cc
User & Date: drh 2019-09-12 16:51:09
Context
2019-09-12
17:11
Use strchr() to improve the performance of defossilize(). check-in: 0aaefeab user: drh tags: trunk
16:51
Use strspn() to improve the performance of validate16(). check-in: c550d6e0 user: drh tags: trunk
16:43
Add the --limit N option to the test-parse-all-blobs test command, so that we can easily limit the run-time of that command for cachegrind performance testing. check-in: 52211ccc user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/encode.c.

644
645
646
647
648
649
650



651
652
653
654
655
656
657
/*
** Return true if the input string contains only valid base-16 digits.
** If any invalid characters appear in the string, return false.
*/
int validate16(const char *zIn, int nIn){
  int i;
  if( nIn<0 ) nIn = (int)strlen(zIn);



  for(i=0; i<nIn; i++, zIn++){
    if( zDecode[zIn[0]&0xff]>63 ){
      return zIn[0]==0;
    }
  }
  return 1;
}







>
>
>







644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/*
** Return true if the input string contains only valid base-16 digits.
** If any invalid characters appear in the string, return false.
*/
int validate16(const char *zIn, int nIn){
  int i;
  if( nIn<0 ) nIn = (int)strlen(zIn);
  if( zIn[nIn]==0 ){
    return strspn(zIn,"0123456789abcdefABCDEF")==nIn;
  }
  for(i=0; i<nIn; i++, zIn++){
    if( zDecode[zIn[0]&0xff]>63 ){
      return zIn[0]==0;
    }
  }
  return 1;
}