ruby-changes:23267
From: nobu <ko1@a...>
Date: Fri, 13 Apr 2012 20:32:15 +0900 (JST)
Subject: [ruby-changes:23267] nobu:r35318 (trunk): * hash.c (no_new_key): moved test to raise outside.
nobu 2012-04-13 20:30:39 +0900 (Fri, 13 Apr 2012) New Revision: 35318 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35318 Log: * hash.c (no_new_key): moved test to raise outside. Modified files: trunk/hash.c Index: hash.c =================================================================== --- hash.c (revision 35317) +++ hash.c (revision 35318) @@ -260,19 +260,18 @@ rb_hash_tbl(hash); } +NORETURN(static void no_new_key(void)); static void -no_new_key(int existing) +no_new_key(void) { - if (!existing) { - rb_raise(rb_eRuntimeError, "can't add a new key into hash during iteration"); - } + rb_raise(rb_eRuntimeError, "can't add a new key into hash during iteration"); } #define NOINSERT_UPDATE_CALLBACK(func) \ int \ func##_noinsert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \ { \ - no_new_key(existing); \ + if (!existing) no_new_key(); \ return func(key, val, arg, existing); \ } @@ -1158,7 +1157,7 @@ rb_hash_modify(hash); if (!tbl) { - if (iter_lev > 0) no_new_key(0); + if (iter_lev > 0) no_new_key(); tbl = RHASH_TBL(hash); } if (tbl->type == &identhash || rb_obj_class(key) != rb_cString) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/