Skip to content

Commit 2c4377c

Browse files
committed
Prevent constant calls to rb_intern
1 parent 22dd62d commit 2c4377c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

ext/rubyhttp.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void RubyHttpConnection_t::ProcessRequest (const char *request_method,
170170
Statics
171171
*******/
172172

173-
173+
VALUE Intern_http_conn;
174174

175175
/***********
176176
t_post_init
@@ -182,7 +182,7 @@ static VALUE t_post_init (VALUE self)
182182
if (!hc)
183183
throw std::runtime_error ("no http-connection object");
184184

185-
rb_ivar_set (self, rb_intern ("@http______conn"), LONG2NUM ((long)hc));
185+
rb_ivar_set (self, Intern_http_conn, LONG2NUM ((long)hc));
186186
return Qnil;
187187
}
188188

@@ -194,7 +194,7 @@ t_receive_data
194194
static VALUE t_receive_data (VALUE self, VALUE data)
195195
{
196196
int length = NUM2INT (rb_funcall (data, rb_intern ("length"), 0));
197-
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, rb_intern ("@http______conn"))));
197+
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, Intern_http_conn)));
198198
if (hc)
199199
hc->ConsumeData (StringValuePtr (data), length);
200200
return Qnil;
@@ -216,7 +216,7 @@ t_unbind
216216

217217
static VALUE t_unbind (VALUE self)
218218
{
219-
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, rb_intern ("@http______conn"))));
219+
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, Intern_http_conn)));
220220
if (hc)
221221
delete hc;
222222
return Qnil;
@@ -240,7 +240,7 @@ t_no_environment_strings
240240

241241
static VALUE t_no_environment_strings (VALUE self)
242242
{
243-
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, rb_intern ("@http______conn"))));
243+
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, Intern_http_conn)));
244244
if (hc)
245245
hc->SetNoEnvironmentStrings();
246246
return Qnil;
@@ -252,7 +252,7 @@ t_dont_accumulate_post
252252

253253
static VALUE t_dont_accumulate_post (VALUE self)
254254
{
255-
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, rb_intern ("@http______conn"))));
255+
RubyHttpConnection_t *hc = (RubyHttpConnection_t*)(NUM2LONG (rb_ivar_get (self, Intern_http_conn)));
256256
if (hc)
257257
hc->SetDontAccumulatePost();
258258
return Qnil;
@@ -276,6 +276,6 @@ extern "C" void Init_eventmachine_httpserver()
276276
rb_define_method (EmModule, "process_http_request", (VALUE(*)(...))t_process_http_request, 0);
277277
rb_define_method (EmModule, "no_environment_strings", (VALUE(*)(...))t_no_environment_strings, 0);
278278
rb_define_method (EmModule, "dont_accumulate_post", (VALUE(*)(...))t_dont_accumulate_post, 0);
279-
}
280-
281279

280+
Intern_http_conn = rb_intern("http_conn");
281+
}

0 commit comments

Comments
 (0)