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: Minor object serialization optimization


Anthony Green wrote:
The overhead of the debugging support in ObjectInputStream seems excessive (from
visual inspection at least :-). Here's one of the obvious offenders. I think we should consider wrapping
all calls to dumpElementln with Configuration.DEBUG && dump checks.
I have an alternative patch I've had sitting for a while.
Of course it only makes a difference if Configuration.DEBUG
is not constantly false, which I guess is never in production,
which is all we care about.  But if Configuration.DEBUG is non-false,
then my code is at least more compact (4 vs 6 method calls),
and possibly faster.

Either is ok to check in.
--
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
Index: ObjectInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/ObjectInputStream.java,v
retrieving revision 1.12
diff -u -r1.12 ObjectInputStream.java
--- ObjectInputStream.java	24 Jul 2002 16:05:34 -0000	1.12
+++ ObjectInputStream.java	7 Sep 2002 20:48:43 -0000
@@ -243,8 +243,16 @@
 	Object array = Array.newInstance (componentType, length);
 	int handle = assignNewHandle (array);
 	readArrayElements (array, componentType);
-	for (int i=0, len=Array.getLength(array); i < len; i++)
-	  dumpElementln ("  ELEMENT[" + i + "]=" + Array.get(array, i));
+	if (Configuration.DEBUG && dump)
+	  {
+	    for (int i=0, len=Array.getLength(array); i < len; i++)
+	      {
+		System.out.print("  ELEMENT[");
+		System.out.print(i);
+		System.out.print("]=");
+		System.out.println(Array.get(array, i));
+	      }
+	  }
 	ret_val = processResolution (array, handle);
 	break;
       }

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