mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c (rb_hash_lookup): added. this function is similar to
rb_hash_aref(), but doesn't call Hash#default when no entry exists. * include/ruby/intern.h: ditto. * insnhelper.ci (lfp_svar_get): use rb_hash_lookup(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bc1e2ab306
commit
302c311199
4 changed files with 23 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Tue Jul 10 19:34:45 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* hash.c (rb_hash_lookup): added. this function is similar to
|
||||
rb_hash_aref(), but doesn't call Hash#default when no entry
|
||||
exists.
|
||||
|
||||
* include/ruby/intern.h: ditto.
|
||||
|
||||
* insnhelper.ci (lfp_svar_get): use rb_hash_lookup().
|
||||
|
||||
Tue Jul 10 19:16:28 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* eval.c, insnhelper.ci, vm.c: change cref index (-1 -> 2).
|
||||
|
|
11
hash.c
11
hash.c
|
@ -401,6 +401,17 @@ rb_hash_aref(VALUE hash, VALUE key)
|
|||
return val;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_hash_lookup(VALUE hash, VALUE key)
|
||||
{
|
||||
VALUE val;
|
||||
|
||||
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
|
||||
return Qnil; /* without Hash#default */
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hsh.fetch(key [, default] ) => obj
|
||||
|
|
|
@ -329,6 +329,7 @@ VALUE rb_hash(VALUE);
|
|||
VALUE rb_hash_new(void);
|
||||
VALUE rb_hash_freeze(VALUE);
|
||||
VALUE rb_hash_aref(VALUE, VALUE);
|
||||
VALUE rb_hash_lookup(VALUE, VALUE);
|
||||
VALUE rb_hash_aset(VALUE, VALUE, VALUE);
|
||||
VALUE rb_hash_delete_if(VALUE);
|
||||
VALUE rb_hash_delete(VALUE,VALUE);
|
||||
|
|
|
@ -788,7 +788,7 @@ lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key)
|
|||
return Qnil;
|
||||
}
|
||||
else {
|
||||
return rb_hash_aref(hash, key);
|
||||
return rb_hash_lookup(hash, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue