--- JSON-XS/XS.xs 2007/06/06 17:49:01 1.37 +++ JSON-XS/XS.xs 2007/06/11 03:18:07 1.38 @@ -34,7 +34,7 @@ #define INIT_SIZE 32 // initial scalar size to be allocated #define INDENT_STEP 3 // spaces per indentation level -#define SHORT_STRING_LEN 512 // special-case strings of up to this size +#define SHORT_STRING_LEN 16384 // special-case strings of up to this size #define SB do { #define SE } while (0) @@ -648,6 +648,7 @@ { SV *sv = 0; int utf8 = 0; + char *dec_cur = dec->cur; do { @@ -656,33 +657,35 @@ do { - unsigned char ch = *(unsigned char *)dec->cur++; + unsigned char ch = *(unsigned char *)dec_cur++; if (expect_false (ch == '"')) { - --dec->cur; + --dec_cur; break; } else if (expect_false (ch == '\\')) { - switch (*dec->cur) + switch (*dec_cur) { case '\\': case '/': - case '"': *cur++ = *dec->cur++; break; + case '"': *cur++ = *dec_cur++; break; - case 'b': ++dec->cur; *cur++ = '\010'; break; - case 't': ++dec->cur; *cur++ = '\011'; break; - case 'n': ++dec->cur; *cur++ = '\012'; break; - case 'f': ++dec->cur; *cur++ = '\014'; break; - case 'r': ++dec->cur; *cur++ = '\015'; break; + case 'b': ++dec_cur; *cur++ = '\010'; break; + case 't': ++dec_cur; *cur++ = '\011'; break; + case 'n': ++dec_cur; *cur++ = '\012'; break; + case 'f': ++dec_cur; *cur++ = '\014'; break; + case 'r': ++dec_cur; *cur++ = '\015'; break; case 'u': { UV lo, hi; - ++dec->cur; + ++dec_cur; + dec->cur = dec_cur; hi = decode_4hex (dec); + dec_cur = dec->cur; if (hi == (UV)-1) goto fail; @@ -690,12 +693,14 @@ if (hi >= 0xd800) if (hi < 0xdc00) { - if (dec->cur [0] != '\\' || dec->cur [1] != 'u') + if (dec_cur [0] != '\\' || dec_cur [1] != 'u') ERR ("missing low surrogate character in surrogate pair"); - dec->cur += 2; + dec_cur += 2; + dec->cur = dec_cur; lo = decode_4hex (dec); + dec_cur = dec->cur; if (lo == (UV)-1) goto fail; @@ -719,7 +724,7 @@ break; default: - --dec->cur; + --dec_cur; ERR ("illegal backslash escape sequence in string"); } } @@ -730,21 +735,21 @@ STRLEN clen; UV uch; - --dec->cur; + --dec_cur; - uch = decode_utf8 (dec->cur, dec->end - dec->cur, &clen); + uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen); if (clen == (STRLEN)-1) ERR ("malformed UTF-8 character in JSON string"); do - *cur++ = *dec->cur++; + *cur++ = *dec_cur++; while (--clen); utf8 = 1; } else { - --dec->cur; + --dec_cur; if (!ch) ERR ("unexpected end of string while parsing JSON string"); @@ -767,9 +772,9 @@ sv = newSVpvn (buf, len); } } - while (*dec->cur != '"'); + while (*dec_cur != '"'); - ++dec->cur; + ++dec_cur; if (sv) { @@ -782,9 +787,11 @@ else sv = newSVpvn ("", 0); + dec->cur = dec_cur; return sv; fail: + dec->cur = dec_cur; return 0; }