ruby-changes:35424
From: normal <ko1@a...>
Date: Wed, 10 Sep 2014 15:01:47 +0900 (JST)
Subject: [ruby-changes:35424] normal:r47506 (trunk): time.c: DATA_PTR is never NULL
normal 2014-09-10 15:01:36 +0900 (Wed, 10 Sep 2014) New Revision: 47506 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47506 Log: time.c: DATA_PTR is never NULL * time.c (time_mark): remove NULL check (time_memsize): ditto (time_free): remove, use RUBY_TYPED_DEFAULT_FREE instead [Feature #10219] Tiny improvement on my old Phenom II X4 945 system: $ ruby --disable=gems -e '6000000.times { Time.now }' before: 2.51user 0.00system 0:02.51elapsed 100%CPU after: 2.45user 0.00system 0:02.45elapsed 100%CPU Modified files: trunk/ChangeLog trunk/time.c Index: time.c =================================================================== --- time.c (revision 47505) +++ time.c (revision 47506) @@ -1782,7 +1782,6 @@ static void https://github.com/ruby/ruby/blob/trunk/time.c#L1782 time_mark(void *ptr) { struct time_object *tobj = ptr; - if (!tobj) return; if (!FIXWV_P(tobj->timew)) rb_gc_mark(w2v(tobj->timew)); rb_gc_mark(tobj->vtm.year); @@ -1790,21 +1789,15 @@ time_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/time.c#L1789 rb_gc_mark(tobj->vtm.utc_offset); } -static void -time_free(void *tobj) -{ - if (tobj) xfree(tobj); -} - static size_t time_memsize(const void *tobj) { - return tobj ? sizeof(struct time_object) : 0; + return sizeof(struct time_object); } static const rb_data_type_t time_data_type = { "time", - {time_mark, time_free, time_memsize,}, + {time_mark, RUBY_TYPED_DEFAULT_FREE, time_memsize,}, NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY }; Index: ChangeLog =================================================================== --- ChangeLog (revision 47505) +++ ChangeLog (revision 47506) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 10 15:00:11 2014 Eric Wong <e@8...> + + * time.c (time_mark): remove NULL check + (time_memsize): ditto + (time_free): remove, use RUBY_TYPED_DEFAULT_FREE instead + [Feature #10219] + Wed Sep 10 14:14:57 2014 NAKAMURA Usaku <usa@r...> * common.mk (encs enc trans libencs libenc libtrans): force to run -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/