apparently these random changes managed to bring tokenizing an 11mb file's time down by 10 seconds on my PC
This commit is contained in:
parent
5a199ae8f6
commit
0c758e3f63
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ PLFLAGS=
|
|||
LIBNAME=
|
||||
OUTDIR=bin
|
||||
LFLAGS=-shared -g -ggdb
|
||||
CFLAGS=--std=c99 -g -ggdb -Wall
|
||||
CFLAGS=--std=c99 -g -ggdb -O2 -Wall
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CC+=mingw32-gcc
|
||||
|
|
23
src/lt.c
23
src/lt.c
|
@ -688,6 +688,9 @@ LT_Token LT_GetToken()
|
|||
return tk;
|
||||
}
|
||||
|
||||
|
||||
if(stringChars[0] != '\0')
|
||||
{
|
||||
for(size_t i = 0; i < 6;)
|
||||
{
|
||||
char cc = stringChars[i++];
|
||||
|
@ -698,12 +701,15 @@ LT_Token LT_GetToken()
|
|||
}
|
||||
else if(c == cc)
|
||||
{
|
||||
tk.string = LT_ReadString(c);
|
||||
tk.token = LT_TkNames[TOK_String];
|
||||
tk.string = LT_ReadString(c);
|
||||
return tk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(charChars[0] != '\0')
|
||||
{
|
||||
for(size_t i = 0; i < 6;)
|
||||
{
|
||||
char cc = charChars[i++];
|
||||
|
@ -714,18 +720,19 @@ LT_Token LT_GetToken()
|
|||
}
|
||||
else if(c == cc)
|
||||
{
|
||||
tk.string = LT_ReadString(c);
|
||||
tk.token = LT_TkNames[TOK_Charac];
|
||||
tk.string = LT_ReadString(c);
|
||||
return tk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(c))
|
||||
{
|
||||
ungetc(c, parseFile);
|
||||
|
||||
tk.string = LT_ReadNumber();
|
||||
tk.token = LT_TkNames[TOK_Number];
|
||||
tk.string = LT_ReadNumber();
|
||||
return tk;
|
||||
}
|
||||
|
||||
|
@ -743,11 +750,6 @@ LT_Token LT_GetToken()
|
|||
|
||||
str[i++] = c;
|
||||
|
||||
if(info.stripInvalid)
|
||||
{
|
||||
str[i++] = (isspace(c) || isprint(c)) ? c : ' ';
|
||||
}
|
||||
|
||||
c = fgetc(parseFile);
|
||||
}
|
||||
|
||||
|
@ -760,19 +762,18 @@ LT_Token LT_GetToken()
|
|||
|
||||
ungetc(c, parseFile);
|
||||
|
||||
tk.string = LT_SetGarbage(LT_ReAlloc(str, i));
|
||||
tk.token = LT_TkNames[TOK_Identi];
|
||||
tk.string = LT_SetGarbage(LT_ReAlloc(str, i));
|
||||
return tk;
|
||||
}
|
||||
|
||||
tk.token = LT_TkNames[TOK_ChrSeq];
|
||||
tk.string = LT_Alloc(2);
|
||||
tk.string[0] = c;
|
||||
tk.string[1] = '\0';
|
||||
|
||||
LT_SetGarbage(tk.string);
|
||||
|
||||
tk.token = LT_TkNames[TOK_ChrSeq];
|
||||
|
||||
return tk;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue
Block a user