ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/XS.xs
(Generate patch)

Comparing JSON-XS/XS.xs (file contents):
Revision 1.68 by root, Thu Nov 29 08:37:11 2007 UTC vs.
Revision 1.70 by root, Wed Mar 19 00:44:54 2008 UTC

1000 1000
1001 if (!is_nv) 1001 if (!is_nv)
1002 { 1002 {
1003 int len = dec->cur - start; 1003 int len = dec->cur - start;
1004 1004
1005 // special case the rather common 1..4-digit-int case, assumes 32 bit ints or so 1005 // special case the rather common 1..5-digit-int case
1006 if (*start == '-') 1006 if (*start == '-')
1007 switch (len) 1007 switch (len)
1008 { 1008 {
1009 case 2: return newSViv (-( start [1] - '0' * 1)); 1009 case 2: return newSViv (-( start [1] - '0' * 1));
1010 case 3: return newSViv (-( start [1] * 10 + start [2] - '0' * 11)); 1010 case 3: return newSViv (-( start [1] * 10 + start [2] - '0' * 11));
1011 case 4: return newSViv (-( start [1] * 100 + start [2] * 10 + start [3] - '0' * 111)); 1011 case 4: return newSViv (-( start [1] * 100 + start [2] * 10 + start [3] - '0' * 111));
1012 case 5: return newSViv (-(start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 1111)); 1012 case 5: return newSViv (-( start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 1111));
1013 case 6: return newSViv (-(start [1] * 10000 + start [2] * 1000 + start [3] * 100 + start [4] * 10 + start [5] - '0' * 11111));
1013 } 1014 }
1014 else 1015 else
1015 switch (len) 1016 switch (len)
1016 { 1017 {
1017 case 1: return newSViv ( start [0] - '0' * 1); 1018 case 1: return newSViv ( start [0] - '0' * 1);
1018 case 2: return newSViv ( start [0] * 10 + start [1] - '0' * 11); 1019 case 2: return newSViv ( start [0] * 10 + start [1] - '0' * 11);
1019 case 3: return newSViv ( start [0] * 100 + start [1] * 10 + start [2] - '0' * 111); 1020 case 3: return newSViv ( start [0] * 100 + start [1] * 10 + start [2] - '0' * 111);
1020 case 4: return newSViv ( start [0] * 1000 + start [1] * 100 + start [2] * 10 + start [3] - '0' * 1111); 1021 case 4: return newSViv ( start [0] * 1000 + start [1] * 100 + start [2] * 10 + start [3] - '0' * 1111);
1022 case 5: return newSViv ( start [0] * 10000 + start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 11111);
1021 } 1023 }
1022 1024
1023 { 1025 {
1024 UV uv; 1026 UV uv;
1025 int numtype = grok_number (start, len, &uv); 1027 int numtype = grok_number (start, len, &uv);
1603 SvREFCNT_dec (self->cb_sk_object); 1605 SvREFCNT_dec (self->cb_sk_object);
1604 SvREFCNT_dec (self->cb_object); 1606 SvREFCNT_dec (self->cb_object);
1605 1607
1606PROTOTYPES: ENABLE 1608PROTOTYPES: ENABLE
1607 1609
1608void to_json (SV *scalar) 1610void encode_json (SV *scalar)
1609 PPCODE: 1611 PPCODE:
1610{ 1612{
1611 JSON json = { F_DEFAULT | F_UTF8 }; 1613 JSON json = { F_DEFAULT | F_UTF8 };
1612 XPUSHs (encode_json (scalar, &json)); 1614 XPUSHs (encode_json (scalar, &json));
1613} 1615}
1614 1616
1615void from_json (SV *jsonstr) 1617void decode_json (SV *jsonstr)
1616 PPCODE: 1618 PPCODE:
1617{ 1619{
1618 JSON json = { F_DEFAULT | F_UTF8 }; 1620 JSON json = { F_DEFAULT | F_UTF8 };
1619 XPUSHs (decode_json (jsonstr, &json, 0)); 1621 XPUSHs (decode_json (jsonstr, &json, 0));
1620} 1622}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines