From 5da34572a5b2b9f57699b997f1892774bd5294b0 Mon Sep 17 00:00:00 2001 From: normal Date: Thu, 2 Jul 2015 01:58:14 +0000 Subject: socket: memoize common socket families in fptr->mode This provides a minor speedup by avoiding an extra syscall require 'socket' require 'benchmark' nr = 100000 msg = 'hello world' buf = '' size = msg.bytesize puts(Benchmark.measure do UNIXSocket.pair(:SEQPACKET) do |a, b| nr.times do a.sendmsg_nonblock(msg, 0, exception: false) b.recv(size, 0, buf) end end end) user system total real before: 0.330000 0.340000 0.670000 ( 0.678235) after: 0.290000 0.240000 0.530000 ( 0.534527) * ext/socket/rubysocket.h: flags for common socket families (rsock_getfamily): update signature * include/ruby/io.h: comment socket FMODE flags * ext/socket/init.c (rsock_getfamily): memoize family * ext/socket/basicsocket.c: adjust rsock_getfamily calls * ext/socket/ancdata.c: ditto [ruby-core:69713] [Feature #11298] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/io.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/ruby') diff --git a/include/ruby/io.h b/include/ruby/io.h index 048090c27a..029522bedc 100644 --- a/include/ruby/io.h +++ b/include/ruby/io.h @@ -113,6 +113,9 @@ typedef struct rb_io_t { #define FMODE_TEXTMODE 0x00001000 /* #define FMODE_PREP 0x00010000 */ #define FMODE_SETENC_BY_BOM 0x00100000 +/* #define FMODE_UNIX 0x00200000 */ +/* #define FMODE_INET 0x00400000 */ +/* #define FMODE_INET6 0x00800000 */ #define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr) -- cgit v1.2.3