解决Maat JSON加载时间过长的问题:由json转换的iris格式用\n换行,但是读取iris格式时先搜索"\r"后搜索"\n",导致搜索时间过长。

This commit is contained in:
zhengchao
2020-03-31 19:52:26 +08:00
parent 54c5cf9d86
commit ecaab32f02
2 changed files with 5 additions and 12 deletions

View File

@@ -32,18 +32,11 @@ char* read_nxt_line_from_buff(const char* buff, size_t buff_size, size_t* offset
{
int this_offset=0;
const char* p;
//search for CRLF, aka '\r', '\n' or "\r\n"
p=(const char*)memchr(buff+*offset,'\r',buff_size-*offset);
if(p==NULL)
//search for CRLF, aka CR '\r'(old Mac), LF '\n'(UNIX) or CRLF"\r\n" (Windows)
p=(const char*)memchr(buff+*offset,'\n',buff_size-*offset);
if(p==NULL)// NOT "\n" or "\r\n"
{
p=(const char*)memchr(buff+*offset,'\n',buff_size-*offset);
}
else
{
if((size_t)(p-buff)<buff_size-1 && *(p+1)=='\n')
{
p++;
}
p=(const char*)memchr(buff+*offset,'\r',buff_size-*offset);
}
if(p!=NULL)//point to next character
{