diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-27 16:45:56 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-27 16:45:56 +0000 |
commit | d9987aa704e5b94983aac43804269b52902e7fc4 (patch) | |
tree | 307abc855e097e9b6a2ed1d8a15d29a8646c1cec /parse.y | |
parent | caa535286d7442ddcbc1caf9fb2778efd435c56d (diff) | |
download | ruby-d9987aa704e5b94983aac43804269b52902e7fc4.tar.gz |
* parse.y (rb_intern2): don't allocate a string object at first.
[ruby-dev:31064]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -8389,11 +8389,17 @@ ID rb_intern2(const char *name, long len) { const char *m = name; - VALUE str = rb_str_new(name, len); + VALUE str; ID id; int last; - - if (st_lookup(global_symbols.sym_id, (st_data_t)str, (st_data_t *)&id)) + struct RString fake_str; + fake_str.basic.flags = T_STRING|RSTRING_NOEMBED|FL_FREEZE; + fake_str.basic.klass = rb_cString; + fake_str.as.heap.len = len; + fake_str.as.heap.ptr = name; + fake_str.as.heap.aux.capa = len; + + if (st_lookup(global_symbols.sym_id, (st_data_t)&fake_str, (st_data_t *)&id)) return id; last = len-1; @@ -8453,6 +8459,7 @@ rb_intern2(const char *name, long len) new_id: id |= ++global_symbols.last_id << ID_SCOPE_SHIFT; id_register: + str = rb_str_new(name, len); OBJ_FREEZE(str); st_add_direct(global_symbols.sym_id, (st_data_t)str, id); st_add_direct(global_symbols.id_str, id, (st_data_t)str); |