public
Description: New and ultra-turbo-crazy-fast backend for Thin
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin-turbo.git
Search Repo:
Refactor buffer_to_ruby_obj
macournoyer (author)
Wed Apr 30 20:42:18 -0700 2008
commit  c1e069fc34f4a5964770375db8b938f4126aa435
tree    f82c0b41384f7dcc3e658b113185dacc15e7c134
parent  75715402dde0955023b07c4ae51a465f2a85ba17
...
3
4
5
 
6
7
8
...
10
11
12
 
13
14
15
...
3
4
5
6
7
8
9
...
11
12
13
14
15
16
17
0
@@ -3,6 +3,7 @@
0
 #define EV_STANDALONE 1
0
 #include <ev.c>
0
 
0
+VALUE cStringIO;
0
 VALUE sInternedCall;
0
 VALUE sInternedKeys;
0
 VALUE sRackInput;
0
@@ -10,6 +11,7 @@
0
 void Init_thin_backend()
0
 {
0
   /* Intern some Ruby strings and symbols */
0
+ cStringIO = rb_define_class("StringIO", rb_cData);
0
   sInternedCall = rb_intern("call");
0
   sInternedKeys = rb_intern("keys");
0
   sRackInput = rb_obj_freeze(rb_str_new2("rack.input"));
...
2
3
4
5
6
7
8
9
...
11
12
13
14
15
16
17
 
 
18
19
20
...
2
3
4
 
 
5
6
7
...
9
10
11
 
 
 
 
12
13
14
15
16
0
@@ -2,8 +2,6 @@
0
 
0
 static VALUE buffer_to_ruby_obj(buffer_t *buf)
0
 {
0
- /* TODO move values to static */
0
-
0
   if (buffer_in_file(buf)) {
0
     /* close the fd and reopen in a Ruby File object */
0
     close(buf->file.fd);
0
@@ -11,10 +9,8 @@
0
     return rb_class_new_instance(1, &fname, rb_cFile);
0
     
0
   } else {
0
- /* no ref to StringIO, redefine to get ref */
0
- /* TODO if read_buffer empty use a generic empty StringIO ? */
0
- VALUE cStringIO = rb_define_class("StringIO", rb_cData);
0
- return rb_funcall(cStringIO, rb_intern("new"), 1, rb_str_new(buf->ptr, buf->len));
0
+ VALUE str = rb_str_new(buf->ptr, buf->len);
0
+ return rb_class_new_instance(1, &str, cStringIO);
0
     
0
   }
0
 }
...
116
117
118
 
119
120
121
...
116
117
118
119
120
121
122
0
@@ -116,6 +116,7 @@
0
 
0
 #define log_errno(b) log_error(b, strerror(errno))
0
 
0
+extern VALUE cStringIO;
0
 extern VALUE sInternedCall;
0
 extern VALUE sInternedKeys;
0
 extern VALUE sRackInput;

Comments

    No one has commented yet.