diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-03-13 09:54:37 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-03-13 09:54:37 +0000 |
commit | 00864a06a860c31f0b139a543f07d94dd37c8a59 (patch) | |
tree | 1b11616d280c96d2f63898e08a48fb7100b5b470 | |
parent | bd8334f5f3e901a3d54d3421dffb0db8efa024a9 (diff) | |
download | clogger-00864a06a860c31f0b139a543f07d94dd37c8a59.tar.gz |
avoid potential RString -> C-string conversions
Unlikely, but it may make a difference somewhere...
-rw-r--r-- | ext/clogger_ext/clogger.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index 0adefa4..9fe1e58 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -888,23 +888,25 @@ static VALUE respond_to(VALUE self, VALUE method) static VALUE to_path(VALUE self) { struct clogger *c = clogger_get(self); - VALUE path = rb_funcall(c->body, to_path_id, 0); struct stat sb; int rv; - unsigned devfd; - const char *cpath = StringValueCStr(path); + VALUE path = rb_funcall(c->body, to_path_id, 0); /* try to avoid an extra path lookup */ - if (rb_respond_to(c->body, to_io_id)) + if (rb_respond_to(c->body, to_io_id)) { rv = fstat(my_fileno(c->body), &sb); - /* - * Rainbows! can use "/dev/fd/%u" in to_path output to avoid - * extra open() syscalls, too. - */ - else if (sscanf(cpath, "/dev/fd/%u", &devfd) == 1) - rv = fstat((int)devfd, &sb); - else - rv = stat(cpath, &sb); + } else { + const char *cpath = StringValueCStr(path); + unsigned devfd; + /* + * Rainbows! can use "/dev/fd/%u" in to_path output to avoid + * extra open() syscalls, too. + */ + if (sscanf(cpath, "/dev/fd/%u", &devfd) == 1) + rv = fstat((int)devfd, &sb); + else + rv = stat(cpath, &sb); + } /* * calling this method implies the web server will bypass |