1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Build error method name at failure

So `struct nmin_data` size is reduced.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-12-05 01:11:32 +00:00
parent 36f05c80b6
commit e7fad40cf2

11
enum.c
View file

@ -1329,16 +1329,17 @@ struct nmin_data {
VALUE buf; VALUE buf;
VALUE limit; VALUE limit;
int (*cmpfunc)(const void *, const void *, void *); int (*cmpfunc)(const void *, const void *, void *);
int rev; /* max if 1 */ int rev: 1; /* max if 1 */
int by; /* min_by if 1 */ int by: 1; /* min_by if 1 */
const char *method;
}; };
static VALUE static VALUE
cmpint_reenter_check(struct nmin_data *data, VALUE val) cmpint_reenter_check(struct nmin_data *data, VALUE val)
{ {
if (RBASIC(data->buf)->klass) { if (RBASIC(data->buf)->klass) {
rb_raise(rb_eRuntimeError, "%s reentered", data->method); rb_raise(rb_eRuntimeError, "%s%s reentered",
data->rev ? "max" : "min",
data->by ? "_by" : "");
} }
return val; return val;
} }
@ -1503,8 +1504,6 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary)
nmin_cmp; nmin_cmp;
data.rev = rev; data.rev = rev;
data.by = by; data.by = by;
data.method = rev ? (by ? "max_by" : "max")
: (by ? "min_by" : "min");
if (ary) { if (ary) {
long i; long i;
for (i = 0; i < RARRAY_LEN(obj); i++) { for (i = 0; i < RARRAY_LEN(obj); i++) {