Skip to content

Commit 1bc41a6

Browse files
authored
Merge pull request #6827 from ahorek/locals
reduce some repeated method calls
2 parents 989bdd8 + 83f195b commit 1bc41a6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import jnr.ffi.annotations.Out;
3939
import jnr.ffi.byref.IntByReference;
4040
import jnr.posix.Timeval;
41+
import jnr.posix.POSIX;
4142
import jnr.unixsocket.UnixSocketAddress;
4243
import org.jruby.Ruby;
4344
import org.jruby.RubyArray;
@@ -807,8 +808,9 @@ protected IRubyObject getSocknameCommon(ThreadContext context, String caller) {
807808
return Sockaddr.pack_sockaddr_in(context, getInetSocketAddress());
808809
}
809810

810-
if (getUnixSocketAddress() != null) {
811-
return Sockaddr.pack_sockaddr_un(context, getUnixSocketAddress().path());
811+
UnixSocketAddress unix = getUnixSocketAddress();
812+
if (unix != null) {
813+
return Sockaddr.pack_sockaddr_un(context, unix.path());
812814
}
813815

814816
return Sockaddr.pack_sockaddr_in(context, 0, "0.0.0.0");
@@ -872,10 +874,11 @@ public boolean doNotReverseLookup(ThreadContext context) {
872874
}
873875

874876
protected static ChannelFD newChannelFD(Ruby runtime, Channel channel) {
875-
ChannelFD fd = new ChannelFD(channel, runtime.getPosix(), runtime.getFilenoUtil());
877+
POSIX posix = runtime.getPosix();
878+
ChannelFD fd = new ChannelFD(channel, posix, runtime.getFilenoUtil());
876879

877-
if (runtime.getPosix().isNative() && fd.realFileno >= 0 && !Platform.IS_WINDOWS) {
878-
runtime.getPosix().fcntlInt(fd.realFileno, Fcntl.F_SETFD, FcntlLibrary.FD_CLOEXEC);
880+
if (posix.isNative() && fd.realFileno >= 0 && !Platform.IS_WINDOWS) {
881+
posix.fcntlInt(fd.realFileno, Fcntl.F_SETFD, FcntlLibrary.FD_CLOEXEC);
879882
}
880883

881884
return fd;

0 commit comments

Comments
 (0)