Skip to content

Commit

Permalink
imrove speed
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jan 31, 2025
1 parent 2b57932 commit 662cf20
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hcxpcapngtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -5737,16 +5737,20 @@ return;
static bool processnmeainfile(char *nmeainname)
{
static int nlen;
static int ccs;
static int ncs;
static uint8_t ccs;
static uint8_t ncs;
static int c;
uint8_t idx0;
uint8_t idx1;
static FILE *fh_nmeain;
static char *ntok;
static char *nres;
const uint8_t hashmap[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>?
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG
Expand All @@ -5765,9 +5769,7 @@ if((fh_nmeain = fopen(nmeainname, "r")) != NULL)
if(nlen < 6) continue;
if(linein[0] != '$') continue;
if(linein[nlen -3] != '*') continue;
idx0 = ((uint8_t)linein[nlen -2] & 0x1F) ^ 0x10;
idx1 = ((uint8_t)linein[nlen -1] & 0x1F) ^ 0x10;
ncs = (uint8_t)(hashmap[idx0] << 4) | hashmap[idx1];
ncs = (hashmap[(uint8_t)linein[nlen -2]] << 4) | hashmap[(uint8_t)linein[nlen -1]];
ccs = 0;
for(c = 1; c < nlen -3; c++) ccs ^= linein[c];
if(ncs != ccs) continue;
Expand Down

0 comments on commit 662cf20

Please sign in to comment.