ruby-changes:39508
From: nagachika <ko1@a...>
Date: Sun, 16 Aug 2015 03:10:31 +0900 (JST)
Subject: [ruby-changes:39508] nagachika:r51589 (ruby_2_2): merge revision(s) 51410: [Backport #11396]
nagachika 2015-08-16 03:10:16 +0900 (Sun, 16 Aug 2015) New Revision: 51589 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51589 Log: merge revision(s) 51410: [Backport #11396] * symbol.h (struct RSymbol): add hashval field * symbol.c (dsymbol_alloc): setup hashval field once * hash.c (rb_any_hash): return RSymbol->hashval directly * common.mk: hash.o depends on symbol.h Thanks to Bruno Escherl <bruno@e...> for the bug report [ruby-core:70129] [Bug #11396] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/common.mk branches/ruby_2_2/hash.c branches/ruby_2_2/symbol.c branches/ruby_2_2/symbol.h branches/ruby_2_2/version.h Index: ruby_2_2/symbol.c =================================================================== --- ruby_2_2/symbol.c (revision 51588) +++ ruby_2_2/symbol.c (revision 51589) @@ -506,12 +506,18 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/symbol.c#L506 dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const ID type) { const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED); + st_index_t hashval; rb_enc_associate(dsym, enc); OBJ_FREEZE(dsym); RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str); RSYMBOL(dsym)->id = type; + /* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */ + hashval = rb_str_hash(str); + hashval <<= 1; + RSYMBOL(dsym)->hashval = (st_index_t)RSHIFT(hashval, 1); + register_sym(str, dsym); rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue); Index: ruby_2_2/symbol.h =================================================================== --- ruby_2_2/symbol.h (revision 51588) +++ ruby_2_2/symbol.h (revision 51589) @@ -25,6 +25,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/symbol.h#L25 struct RSymbol { struct RBasic basic; + st_index_t hashval; VALUE fstr; ID id; }; Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 51588) +++ ruby_2_2/ChangeLog (revision 51589) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sun Aug 16 03:00:44 2015 Eric Wong <e@8...> + + * symbol.h (struct RSymbol): add hashval field + * symbol.c (dsymbol_alloc): setup hashval field once + * hash.c (rb_any_hash): return RSymbol->hashval directly + * common.mk: hash.o depends on symbol.h + Thanks to Bruno Escherl <bruno@e...> for the bug report + [ruby-core:70129] [Bug #11396] + Fri Aug 14 16:30:43 2015 Nobuyoshi Nakada <nobu@r...> * transcode.c (rb_econv_set_replacement): target encoding name can Index: ruby_2_2/common.mk =================================================================== --- ruby_2_2/common.mk (revision 51588) +++ ruby_2_2/common.mk (revision 51589) @@ -1450,6 +1450,7 @@ hash.$(OBJEXT): {$(VPATH)}oniguruma.h https://github.com/ruby/ruby/blob/trunk/ruby_2_2/common.mk#L1450 hash.$(OBJEXT): {$(VPATH)}probes.h hash.$(OBJEXT): {$(VPATH)}st.h hash.$(OBJEXT): {$(VPATH)}subst.h +hash.$(OBJEXT): {$(VPATH)}symbol.h hash.$(OBJEXT): {$(VPATH)}util.h hash.$(OBJEXT): {$(VPATH)}vm_opts.h inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h Index: ruby_2_2/hash.c =================================================================== --- ruby_2_2/hash.c (revision 51588) +++ ruby_2_2/hash.c (revision 51589) @@ -17,6 +17,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/hash.c#L17 #include <errno.h> #include "probes.h" #include "id.h" +#include "symbol.h" #ifdef __APPLE__ # ifdef HAVE_CRT_EXTERNS_H @@ -150,7 +151,7 @@ rb_any_hash(VALUE a) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/hash.c#L151 hnum = rb_str_hash(a); } else if (BUILTIN_TYPE(a) == T_SYMBOL) { - hnum = rb_objid_hash((st_index_t)a); + return RSYMBOL(a)->hashval; } else if (BUILTIN_TYPE(a) == T_FLOAT) { flt: Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 51588) +++ ruby_2_2/version.h (revision 51589) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.3" -#define RUBY_RELEASE_DATE "2015-08-14" -#define RUBY_PATCHLEVEL 167 +#define RUBY_RELEASE_DATE "2015-08-16" +#define RUBY_PATCHLEVEL 168 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 14 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r51410 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/