diff options
| author | cremno <[email protected]> | 2014-02-13 13:36:55 +0100 |
|---|---|---|
| committer | cremno <[email protected]> | 2014-02-13 13:39:09 +0100 |
| commit | 4ffea85b62d49944524f4b5211b79f3009b8d3bd (patch) | |
| tree | 1d23b8d825b0681add7b8a73519f0e9dc61c7998 /mrbgems/mruby-hash-ext | |
| parent | 7a32c7b18354c3f4f0439978797157bf9915ae2a (diff) | |
| download | mruby-4ffea85b62d49944524f4b5211b79f3009b8d3bd.tar.gz mruby-4ffea85b62d49944524f4b5211b79f3009b8d3bd.zip | |
hash / hash-ext: various small changes
src/hash.c:
- mrb_hash_(aget|aset|dup|delete): internal linkage
- remove documentation of methods which are not implemented (in here)
- remove #assoc; unused, not in ISO spec
- remove #rassoc: same, implementation is also wrong
hash-ext mrbgem:
- remove header "mruby/khash.h"
- remove mrb_hash_values_at (move code into hash_values_at, i: long -> int)
- less whitespace in gem_init function
Diffstat (limited to 'mrbgems/mruby-hash-ext')
| -rw-r--r-- | mrbgems/mruby-hash-ext/src/hash-ext.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/mrbgems/mruby-hash-ext/src/hash-ext.c b/mrbgems/mruby-hash-ext/src/hash-ext.c index c6e72f451..298559686 100644 --- a/mrbgems/mruby-hash-ext/src/hash-ext.c +++ b/mrbgems/mruby-hash-ext/src/hash-ext.c @@ -7,7 +7,6 @@ #include "mruby.h" #include "mruby/array.h" #include "mruby/hash.h" -#include "mruby/khash.h" /* * call-seq: @@ -20,27 +19,18 @@ * h.values_at("cow", "cat") #=> ["bovine", "feline"] */ -mrb_value -mrb_hash_values_at(mrb_state *mrb, int argc, mrb_value *argv, mrb_value hash) -{ - mrb_value result = mrb_ary_new_capa(mrb, argc); - long i; - - for (i=0; i<argc; i++) { - mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i])); - } - return result; -} - static mrb_value hash_values_at(mrb_state *mrb, mrb_value hash) { - mrb_value *argv; - int argc; + mrb_value *argv, result; + int argc, i; mrb_get_args(mrb, "*", &argv, &argc); - - return mrb_hash_values_at(mrb, argc, argv, hash); + result = mrb_ary_new_capa(mrb, argc); + for (i = 0; i < argc; i++) { + mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i])); + } + return result; } void @@ -49,8 +39,7 @@ mrb_mruby_hash_ext_gem_init(mrb_state *mrb) struct RClass *h; h = mrb->hash_class; - - mrb_define_method(mrb, h, "values_at", hash_values_at, MRB_ARGS_ANY()); + mrb_define_method(mrb, h, "values_at", hash_values_at, MRB_ARGS_ANY()); } void |
