--- JSON-XS/XS.xs 2007/07/26 11:33:35 1.56 +++ JSON-XS/XS.xs 2007/08/13 16:05:42 1.57 @@ -60,6 +60,12 @@ #define expect_false(expr) expect ((expr) != 0, 0) #define expect_true(expr) expect ((expr) != 0, 1) +#ifdef USE_ITHREADS +# define JSON_SLOW 1 +#else +# define JSON_SLOW 1 +#endif + static HV *json_stash, *json_boolean_stash; // JSON::XS:: static SV *json_true, *json_false; @@ -480,7 +486,11 @@ if (expect_false (SvOBJECT (sv))) { - if (SvSTASH (sv) == json_boolean_stash) + HV *stash = !JSON_SLOW || json_boolean_stash + ? json_boolean_stash + : gv_stashpv ("JSON::XS::Boolean", 1); + + if (SvSTASH (sv) == stash) { if (SvIV (sv)) encode_str (enc, "true", 4, 0); @@ -1363,14 +1373,22 @@ PROTOTYPES: DISABLE +void CLONE (...) + CODE: + json_stash = 0; + json_boolean_stash = 0; + void new (char *klass) PPCODE: { + HV *stash = !JSON_SLOW || json_stash + ? json_stash + : gv_stashpv ("JSON::XS", 1); SV *pv = NEWSV (0, sizeof (JSON)); SvPOK_only (pv); Zero (SvPVX (pv), 1, JSON); ((JSON *)SvPVX (pv))->flags = F_DEFAULT; - XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), json_stash))); + XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), stash))); } void ascii (JSON *self, int enable = 1)