mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
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@escherl.net> for the bug report [ruby-core:70129] [Bug #11396] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
62550b1d0f
commit
343b2aa615
6 changed files with 22 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Sun Aug 16 03:00:44 2015 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
|
* 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@escherl.net> for the bug report
|
||||||
|
[ruby-core:70129] [Bug #11396]
|
||||||
|
|
||||||
Fri Aug 14 16:30:43 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Aug 14 16:30:43 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* transcode.c (rb_econv_set_replacement): target encoding name can
|
* transcode.c (rb_econv_set_replacement): target encoding name can
|
||||||
|
|
|
@ -1450,6 +1450,7 @@ hash.$(OBJEXT): {$(VPATH)}oniguruma.h
|
||||||
hash.$(OBJEXT): {$(VPATH)}probes.h
|
hash.$(OBJEXT): {$(VPATH)}probes.h
|
||||||
hash.$(OBJEXT): {$(VPATH)}st.h
|
hash.$(OBJEXT): {$(VPATH)}st.h
|
||||||
hash.$(OBJEXT): {$(VPATH)}subst.h
|
hash.$(OBJEXT): {$(VPATH)}subst.h
|
||||||
|
hash.$(OBJEXT): {$(VPATH)}symbol.h
|
||||||
hash.$(OBJEXT): {$(VPATH)}util.h
|
hash.$(OBJEXT): {$(VPATH)}util.h
|
||||||
hash.$(OBJEXT): {$(VPATH)}vm_opts.h
|
hash.$(OBJEXT): {$(VPATH)}vm_opts.h
|
||||||
inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h
|
inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h
|
||||||
|
|
3
hash.c
3
hash.c
|
@ -17,6 +17,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "probes.h"
|
#include "probes.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
#include "symbol.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# ifdef HAVE_CRT_EXTERNS_H
|
# ifdef HAVE_CRT_EXTERNS_H
|
||||||
|
@ -150,7 +151,7 @@ rb_any_hash(VALUE a)
|
||||||
hnum = rb_str_hash(a);
|
hnum = rb_str_hash(a);
|
||||||
}
|
}
|
||||||
else if (BUILTIN_TYPE(a) == T_SYMBOL) {
|
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) {
|
else if (BUILTIN_TYPE(a) == T_FLOAT) {
|
||||||
flt:
|
flt:
|
||||||
|
|
6
symbol.c
6
symbol.c
|
@ -506,12 +506,18 @@ static VALUE
|
||||||
dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const ID type)
|
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);
|
const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED);
|
||||||
|
st_index_t hashval;
|
||||||
|
|
||||||
rb_enc_associate(dsym, enc);
|
rb_enc_associate(dsym, enc);
|
||||||
OBJ_FREEZE(dsym);
|
OBJ_FREEZE(dsym);
|
||||||
RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str);
|
RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str);
|
||||||
RSYMBOL(dsym)->id = type;
|
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);
|
register_sym(str, dsym);
|
||||||
rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue);
|
rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue);
|
||||||
|
|
||||||
|
|
1
symbol.h
1
symbol.h
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
struct RSymbol {
|
struct RSymbol {
|
||||||
struct RBasic basic;
|
struct RBasic basic;
|
||||||
|
st_index_t hashval;
|
||||||
VALUE fstr;
|
VALUE fstr;
|
||||||
ID id;
|
ID id;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.2.3"
|
#define RUBY_VERSION "2.2.3"
|
||||||
#define RUBY_RELEASE_DATE "2015-08-14"
|
#define RUBY_RELEASE_DATE "2015-08-16"
|
||||||
#define RUBY_PATCHLEVEL 167
|
#define RUBY_PATCHLEVEL 168
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2015
|
#define RUBY_RELEASE_YEAR 2015
|
||||||
#define RUBY_RELEASE_MONTH 8
|
#define RUBY_RELEASE_MONTH 8
|
||||||
#define RUBY_RELEASE_DAY 14
|
#define RUBY_RELEASE_DAY 16
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue