This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: tcp sockets: removing code duplication


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]