mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Optimise out escapable array.
git-svn-id: svn://svn.code.sf.net/p/cjson/code@67 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
parent
060e6563c0
commit
b44a338c6d
12
cJSON.c
12
cJSON.c
@ -248,22 +248,12 @@ static const char *parse_string(cJSON *item,const char *str)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int escapable[256]={ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
|
|
||||||
0,0,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
|
|
||||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
|
||||||
|
|
||||||
/* Render the cstring provided to an escaped version that can be printed. */
|
/* Render the cstring provided to an escaped version that can be printed. */
|
||||||
static char *print_string_ptr(const char *str,printbuffer *p)
|
static char *print_string_ptr(const char *str,printbuffer *p)
|
||||||
{
|
{
|
||||||
const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;
|
const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;
|
||||||
|
|
||||||
ptr=str;while (*ptr) flag|=escapable[*ptr++];
|
for (ptr=str;*ptr;ptr++) flag|=((*ptr>=0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0;
|
||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
len=ptr-str;
|
len=ptr-str;
|
||||||
|
Loading…
Reference in New Issue
Block a user