optimizing

dev
liuwei 2015-08-18 17:21:50 +08:00
parent ecfafbcf38
commit a9fc4a5a2a
1 changed files with 10 additions and 8 deletions

View File

@ -284,7 +284,7 @@ static int iniDoLoadItemsFromBuffer(char *content, IniContext *pContext)
char *pAnnoItemLine; char *pAnnoItemLine;
char *pIncludeFilename; char *pIncludeFilename;
char *pItemValue[100]; char *pItemValue[100];
char pFunc_name[FAST_INI_ITEM_NAME_LEN + 1]; char pFuncName[FAST_INI_ITEM_NAME_LEN + 1];
char full_filename[MAX_PATH_SIZE]; char full_filename[MAX_PATH_SIZE];
int i; int i;
int nLineLen; int nLineLen;
@ -376,10 +376,12 @@ static int iniDoLoadItemsFromBuffer(char *content, IniContext *pContext)
(*(pLine+10) == ' ' || *(pLine+10) == '\t'))) (*(pLine+10) == ' ' || *(pLine+10) == '\t')))
{ {
nNameLen = strlen(pLine + 11); nNameLen = strlen(pLine + 11);
nNameLen = nNameLen > FAST_INI_ITEM_NAME_LEN ? if (nNameLen > FAST_INI_ITEM_NAME_LEN) {
FAST_INI_ITEM_NAME_LEN : nNameLen; nNameLen = FAST_INI_ITEM_NAME_LEN;
memcpy(pFunc_name, pLine + 11, nNameLen + 1); }
trim(pFunc_name); memcpy(pFuncName, pLine + 11, nNameLen);
pFuncName[nNameLen] = '\0';
trim(pFuncName);
isAnnotation = 1; isAnnotation = 1;
pAnnoItemLine = pLastEnd + 1; pAnnoItemLine = pLastEnd + 1;
continue; continue;
@ -512,7 +514,7 @@ static int iniDoLoadItemsFromBuffer(char *content, IniContext *pContext)
pAnnoMap = g_annotataionMap; pAnnoMap = g_annotataionMap;
while (pAnnoMap->func_name) while (pAnnoMap->func_name)
{ {
if (strcmp(pFunc_name, pAnnoMap->func_name) == 0) if (strcmp(pFuncName, pAnnoMap->func_name) == 0)
{ {
if (pAnnoMap->func_init) if (pAnnoMap->func_init)
{ {
@ -533,7 +535,7 @@ static int iniDoLoadItemsFromBuffer(char *content, IniContext *pContext)
logWarning("file: "__FILE__", line: %d, " \ logWarning("file: "__FILE__", line: %d, " \
"not found corresponding annotation func (%s)" \ "not found corresponding annotation func (%s)" \
" and (%s) will use the item value (%s).", __LINE__, " and (%s) will use the item value (%s).", __LINE__,
pItem->name, pFunc_name, pItem->value); pItem->name, pFuncName, pItem->value);
pSection->count++; pSection->count++;
pItem++; pItem++;
continue; continue;
@ -543,7 +545,7 @@ static int iniDoLoadItemsFromBuffer(char *content, IniContext *pContext)
logWarning("file: "__FILE__", line: %d, " \ logWarning("file: "__FILE__", line: %d, " \
"annotation func(%s) execute failed and" "annotation func(%s) execute failed and"
"(%s) will use the item value (%s)", __LINE__, "(%s) will use the item value (%s)", __LINE__,
pItem->name, pFunc_name, pItem->value); pItem->name, pFuncName, pItem->value);
pSection->count++; pSection->count++;
pItem++; pItem++;
continue; continue;