Skip to content

Commit 8ebac4a

Browse files
committed
ssl: extract rb_intern("call")
1 parent 5c1c0fa commit 8ebac4a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ VALUE cSSLSocket;
3232
static VALUE eSSLErrorWaitReadable;
3333
static VALUE eSSLErrorWaitWritable;
3434

35-
static ID ID_callback_state, id_tmp_dh_callback, id_tmp_ecdh_callback,
35+
static ID id_call, ID_callback_state, id_tmp_dh_callback, id_tmp_ecdh_callback,
3636
id_npn_protocols_encoded;
3737
static VALUE sym_exception, sym_wait_readable, sym_wait_writable;
3838

@@ -205,7 +205,7 @@ ossl_call_client_cert_cb(VALUE obj)
205205
if (NIL_P(cb))
206206
return Qnil;
207207

208-
ary = rb_funcall(cb, rb_intern("call"), 1, obj);
208+
ary = rb_funcallv(cb, id_call, 1, &obj);
209209
Check_Type(ary, T_ARRAY);
210210
GetX509CertPtr(cert = rb_ary_entry(ary, 0));
211211
GetPrivPKeyPtr(key = rb_ary_entry(ary, 1));
@@ -248,8 +248,8 @@ ossl_call_tmp_dh_callback(struct tmp_dh_callback_args *args)
248248
cb = rb_funcall(args->ssl_obj, args->id, 0);
249249
if (NIL_P(cb))
250250
return NULL;
251-
dh = rb_funcall(cb, rb_intern("call"), 3,
252-
args->ssl_obj, INT2NUM(args->is_export), INT2NUM(args->keylength));
251+
dh = rb_funcall(cb, id_call, 3, args->ssl_obj, INT2NUM(args->is_export),
252+
INT2NUM(args->keylength));
253253
pkey = GetPKeyPtr(dh);
254254
if (EVP_PKEY_base_id(pkey) != args->type)
255255
return NULL;
@@ -374,7 +374,7 @@ ossl_call_session_get_cb(VALUE ary)
374374
cb = rb_funcall(ssl_obj, rb_intern("session_get_cb"), 0);
375375
if (NIL_P(cb)) return Qnil;
376376

377-
return rb_funcall(cb, rb_intern("call"), 1, ary);
377+
return rb_funcallv(cb, id_call, 1, &ary);
378378
}
379379

380380
/* this method is currently only called for servers (in OpenSSL <= 0.9.8e) */
@@ -420,7 +420,7 @@ ossl_call_session_new_cb(VALUE ary)
420420
cb = rb_funcall(ssl_obj, rb_intern("session_new_cb"), 0);
421421
if (NIL_P(cb)) return Qnil;
422422

423-
return rb_funcall(cb, rb_intern("call"), 1, ary);
423+
return rb_funcallv(cb, id_call, 1, &ary);
424424
}
425425

426426
/* return 1 normal. return 0 removes the session */
@@ -467,7 +467,7 @@ ossl_call_session_remove_cb(VALUE ary)
467467
cb = rb_attr_get(sslctx_obj, id_i_session_remove_cb);
468468
if (NIL_P(cb)) return Qnil;
469469

470-
return rb_funcall(cb, rb_intern("call"), 1, ary);
470+
return rb_funcallv(cb, id_call, 1, &ary);
471471
}
472472

473473
static void
@@ -533,7 +533,7 @@ ossl_call_servername_cb(VALUE ary)
533533
cb = rb_attr_get(sslctx_obj, id_i_servername_cb);
534534
if (NIL_P(cb)) return Qnil;
535535

536-
ret_obj = rb_funcall(cb, rb_intern("call"), 1, ary);
536+
ret_obj = rb_funcallv(cb, id_call, 1, &ary);
537537
if (rb_obj_is_kind_of(ret_obj, cSSLContext)) {
538538
SSL *ssl;
539539
SSL_CTX *ctx2;
@@ -585,7 +585,7 @@ ssl_renegotiation_cb(const SSL *ssl)
585585
cb = rb_attr_get(sslctx_obj, id_i_renegotiation_cb);
586586
if (NIL_P(cb)) return;
587587

588-
(void) rb_funcall(cb, rb_intern("call"), 1, ssl_obj);
588+
rb_funcallv(cb, id_call, 1, &ssl_obj);
589589
}
590590

591591
#if !defined(OPENSSL_NO_NEXTPROTONEG) || \
@@ -635,7 +635,7 @@ npn_select_cb_common_i(VALUE tmp)
635635
in += l;
636636
}
637637

638-
selected = rb_funcall(args->cb, rb_intern("call"), 1, protocols);
638+
selected = rb_funcallv(args->cb, id_call, 1, &protocols);
639639
StringValue(selected);
640640
len = RSTRING_LEN(selected);
641641
if (len < 1 || len >= 256) {
@@ -2261,6 +2261,7 @@ Init_ossl_ssl(void)
22612261
rb_mWaitWritable = rb_define_module_under(rb_cIO, "WaitWritable");
22622262
#endif
22632263

2264+
id_call = rb_intern("call");
22642265
ID_callback_state = rb_intern("callback_state");
22652266

22662267
ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0, (void *)"ossl_ssl_ex_vcb_idx", 0, 0, 0);

0 commit comments

Comments
 (0)