Optimize the ip2long function with trim logic applied

This commit is contained in:
lionsoul 2018-10-07 10:23:17 +08:00
parent 835d9c1b90
commit d796a76400
2 changed files with 28 additions and 23 deletions

View File

@ -396,6 +396,11 @@ IP2R_API uint_t ip2long(const char *ip)
uint_t ipval = 0;
while ( *cs != '\0' ) {
if ( *cs == ' ' ) {
cs++;
continue;
}
if ( *cs == '.' ) {
//single part length limit
if ( i > 3 ) {

View File

@ -49,7 +49,7 @@ int main( int argc, char **argv )
datablock_entry datablock;
char *dbFile = NULL, *algorithm = NULL;
char line[256];
uint_t (*func_ptr)(ip2region_t, char *, datablock_t);
uint_t (*func_ptr)(ip2region_t, const char *, datablock_t);
double s_time, c_time;
memset(&datablock, 0x00, sizeof(datablock_entry));