Skip to content

Commit

Permalink
inline rb_parser_callback_for
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfryed committed Jun 26, 2012
1 parent 8daaccc commit 3cdca6c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ext/http-parser/ruby_http_parser.c
Expand Up @@ -25,17 +25,13 @@ http_parser* rb_http_parser_handle(VALUE self) {
return parser;
}

VALUE rb_parser_callback_for(VALUE self, VALUE name) {
return rb_hash_aref(rb_iv_get(self, "@callbacks"), name);
}

void rb_parser_callback_call(VALUE self, const char *name, char *data, size_t length) {
VALUE func = rb_parser_callback_for(self, ID2SYM(rb_intern(name)));
if (!NIL_P(func)) {
VALUE callback = rb_hash_aref(rb_iv_get(self, "@callbacks"), ID2SYM(rb_intern(name)));
if (!NIL_P(callback)) {
VALUE args = rb_ary_new();
if (data)
rb_ary_push(args, rb_str_new(data, length));
rb_proc_call(func, args);
rb_proc_call(callback, args);
}
}

Expand Down

0 comments on commit 3cdca6c

Please sign in to comment.