[KinoSearch] Orderly global destruction
Marvin Humphrey
marvin at rectangular.com
Thu Feb 28 12:46:04 PST 2008
On Feb 24, 2008, at 9:20 PM, Nathan Kurz wrote:
>
>> I guess my instinct would be to apply the patch for the slight
>> benefit
>> in directness and performance, but I agree that the benefit is
>> minimal. Still, I think it's a benefit.
A footnote: direct creation had the side effect of wrecking Doc's
overloading in Perl 5.10.
In 5.8, the SVf_AMAGIC flag is held by the outer ref, and in 5.10,
it's held by the inner object. However, turning it on is accomplished
via the outer ref in both cases.
Usage:
SvAMAGIC_on(outer_ref);
Macro def in 5.8.8 (from sv.c):
#define SvAMAGIC_on(sv) (SvFLAGS(sv) |= SVf_AMAGIC)
Macro def in 5.10.0:
# define SvAMAGIC_on(sv) ({ SV * const kloink = sv; \
assert(SvROK(kloink)); \
SvFLAGS(SvRV(kloink)) |= SVf_AMAGIC; \
})
Under the previous "destroy the object in order to save it" algo, the
act of creating the outer ref in 5.10 turned on the SVf_AMAGIC flag on
the inner object. But with direct creating, that wasn't happening
anymore.
The solution was to modify kino_Doc_to_native, which creates an outer
ref, to always invoke SvAMAGIC_on(sv). Previously, it had been set up
to only turn on for 5.8.x.
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
Modified: trunk/perl/xs/KinoSearch/Doc.c
===================================================================
--- trunk/perl/xs/KinoSearch/Doc.c 2008-02-28 14:05:42 UTC (rev 3081)
+++ trunk/perl/xs/KinoSearch/Doc.c 2008-02-28 20:54:47 UTC (rev 3082)
@@ -130,12 +130,8 @@
*/
stash = gv_stashpvn(self->_->class_name, self->_->class_name_len,
true);
Gv_AMupdate(stash);
-
-#if PERL_VERSION < 9
- /* In perl 5.8, the OVERLOAD magic flag is carried in the ref,
while in
- * 5.10, it is carried in the inner object. */
SvAMAGIC_on(perl_obj);
-#endif
+
return perl_obj;
}
_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch
More information about the kinosearch
mailing list