This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: tcp sockets: removing code duplication
- From: Tom Tromey <tromey at redhat dot com>
- To: Michael Koch <konqueror at gmx dot de>
- Cc: java-patches at gcc dot gnu dot org
- Date: 15 Mar 2004 12:20:03 -0700
- Subject: Re: Patch: tcp sockets: removing code duplication
- References: <200403111901.05651.konqueror@gmx.de>
- Reply-to: tromey at redhat dot com
>>>>> "Michael" == Michael Koch <konqueror@gmx.de> writes:
Michael> 2004-03-11 Michael Koch <konqueror@gmx.de>
Michael> * gnu/java/net/natPlainSocketImplPosix.cc
Michael> (write): Just call write(jbyteArray, offset, len).
Michael> (read): Just call read(jbyteArray, offset, len).
Michael> + jbyteArray data = JvNewByteArray (1);
Michael> + (elements (data)) [0] = (jbyte) b;
Michael> + write (data, 0, 1);
Allocating a new array here seems a bit heavy.
How about adding a new helper function that takes a jbyte*?
Then call it from both write(int) and write(byte[],int,int).
The write(int) case would look like:
jbyte value = (jbyte) b;
return really_write (&b, 1);
The other method would end with:
return really_write (elements (array) + offset, len);
Tom