ruby-changes:28866
From: nobu <ko1@a...>
Date: Sat, 25 May 2013 07:04:17 +0900 (JST)
Subject: [ruby-changes:28866] nobu:r40918 (trunk): call rb_frame_callee() only once
nobu 2013-05-25 07:03:41 +0900 (Sat, 25 May 2013) New Revision: 40918 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40918 Log: call rb_frame_callee() only once * eval_error.c (error_pos): no needs to call rb_frame_callee() twice. * safe.c (rb_secure, rb_insecure_operation): ditto. Modified files: trunk/eval_error.c trunk/safe.c Index: eval_error.c =================================================================== --- eval_error.c (revision 40917) +++ eval_error.c (revision 40918) @@ -25,12 +25,13 @@ error_pos(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L25 int sourceline = rb_sourceline(); if (sourcefile) { + ID caller_name; if (sourceline == 0) { warn_printf("%s", sourcefile); } - else if (rb_frame_callee()) { + else if ((caller_name = rb_frame_callee()) != 0) { warn_printf("%s:%d:in `%s'", sourcefile, sourceline, - rb_id2name(rb_frame_callee())); + rb_id2name(caller_name)); } else { warn_printf("%s:%d", sourcefile, sourceline); Index: safe.c =================================================================== --- safe.c (revision 40917) +++ safe.c (revision 40918) @@ -79,9 +79,10 @@ void https://github.com/ruby/ruby/blob/trunk/safe.c#L79 rb_secure(int level) { if (level <= rb_safe_level()) { - if (rb_frame_callee()) { + ID caller_name = rb_frame_callee(); + if (caller_name) { rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d", - rb_id2name(rb_frame_callee()), rb_safe_level()); + rb_id2name(caller_name), rb_safe_level()); } else { rb_raise(rb_eSecurityError, "Insecure operation at level %d", @@ -100,9 +101,10 @@ rb_secure_update(VALUE obj) https://github.com/ruby/ruby/blob/trunk/safe.c#L101 void rb_insecure_operation(void) { - if (rb_frame_callee()) { + ID caller_name = rb_frame_callee(); + if (caller_name) { rb_raise(rb_eSecurityError, "Insecure operation - %s", - rb_id2name(rb_frame_callee())); + rb_id2name(caller_name)); } else { rb_raise(rb_eSecurityError, "Insecure operation: -r"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/