zou lunkai
2008-Oct-30 02:09 UTC
[Swfdec] [Swfdec-commits] 15 commits - doc/swfdec.types swfdec/Makefile.am swfdec/swfdec_amf.c swfdec/swfdec_as_array.c swfdec/swfdec_as_array.h swfdec/swfdec_as_boolean.c swfdec/swfdec_as_boolean.h swfdec/swfdec_as_context.c swfdec/swfdec_as_context.h sw
seems I cann't reply to the commit mail list directly, so forward to the develop mail list. see message bellow. --zou On Thu, Oct 30, 2008 at 9:59 AM, zou lunkai <zoulunkai at gmail.com> wrote:>> +/** >> + * swfdec_as_value_set_number: >> + * @context: The context to use >> + * @val: value to set >> + * @number: double value to set >> + * >> + * Sets @val to the given value. If you are sure the value is a valid >> + * integer value, use wfdec_as_value_set_int() instead. >> + */ >> +void >> +swfdec_as_value_set_number (SwfdecAsContext *context, SwfdecAsValue *val, >>+ double d) >> +{ >> + val->type = SWFDEC_AS_TYPE_NUMBER; >> + val->value.number = g_slice_new (SwfdecAsDoubleValue); >> + val->value.number->number = d; >> + val->value.number->next = context->numbers; >> + context->numbers = val->value.number; >> +} >> + > > In ActionScript, primitive numbers are not GC-collected or reference > counted, aren't they? > > What's the good point to make primitive numbers to be heap allocated? > Is it overkill? > > --zou > >
Benjamin Otte
2008-Oct-30 09:45 UTC
[Swfdec] [Swfdec-commits] 15 commits - doc/swfdec.types swfdec/Makefile.am swfdec/swfdec_amf.c swfdec/swfdec_as_array.c swfdec/swfdec_as_array.h swfdec/swfdec_as_boolean.c swfdec/swfdec_as_boolean.h swfdec/swfdec_as_context.c swfdec/swfdec_as_context.h sw
On Thu, Oct 30, 2008 at 2:59 AM, zou lunkai <zoulunkai at gmail.com> wrote:> In ActionScript, primitive numbers are not GC-collected or reference > counted, aren't they? > > What's the good point to make primitive numbers to be heap allocated? > Is it overkill? >Two things: 1) Performance and memory footprint - you want the value type to be machine size (see every Javascript engine out there). If you put doubles into the value type, you need > 8 bytes (8 for the double and 2 or 3 for the type description) 2) This test: x = 0/0; y = x; z = 0/0; trace (x == y); trace (x == z); In somewhat extended form also available as test/trace/equality-nan*.swf And as you noticed, sending to the commits list is disabled for mere mortals, so all useful discussion happens on the swfdec list. The commits list is just for spam from various bots (Bugzilla, commits, and I still want to hook up the wiki). Cheers, Benjamin