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]

Patch: remove useless memsets


_Jv_AllocBytes is guaranteed to return zero-filled memory.   We don't
need to do any of these memsets.  Ok for HEAD?

AG



2005-04-22  Anthony Green  <green@redhat.com>

	* jni.cc (natrehash): Don't bother clearing memory again.
	* interpret.cc (do_allocate_static_fields): Ditto.
	* java/lang/natString.cc (rehash): Ditto.


Index: interpret.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/interpret.cc,v
retrieving revision 1.49
diff -u -p -r1.49 interpret.cc
--- interpret.cc	10 Mar 2005 19:02:16 -0000	1.49
+++ interpret.cc	22 Apr 2005 07:31:00 -0000
@@ -3751,7 +3751,6 @@ _Jv_InterpreterEngine::do_allocate_stati
   _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
 
   char *static_data = (char *) _Jv_AllocBytes (static_size);
-  memset (static_data, 0, static_size);
 
   for (int i = 0; i < klass->field_count; i++)
     {
Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.96
diff -u -p -r1.96 jni.cc
--- jni.cc	5 Apr 2005 22:26:21 -0000	1.96
+++ jni.cc	22 Apr 2005 07:31:01 -0000
@@ -1847,7 +1847,6 @@ natrehash ()
       nathash =
 	(JNINativeMethod *) _Jv_AllocBytes (nathash_size
 					    * sizeof (JNINativeMethod));
-      memset (nathash, 0, nathash_size * sizeof (JNINativeMethod));
     }
   else
     {
@@ -1857,7 +1856,6 @@ natrehash ()
       nathash =
 	(JNINativeMethod *) _Jv_AllocBytes (nathash_size
 					    * sizeof (JNINativeMethod));
-      memset (nathash, 0, nathash_size * sizeof (JNINativeMethod));
 
       for (int i = 0; i < savesize; ++i)
 	{
Index: java/lang/natString.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natString.cc,v
retrieving revision 1.36
diff -u -p -r1.36 natString.cc
--- java/lang/natString.cc	25 Nov 2004 03:47:05 -0000	1.36
+++ java/lang/natString.cc	22 Apr 2005 07:31:01 -0000
@@ -125,7 +125,6 @@ rehash ()
     {
       strhash_size = 1024;
       strhash = (jstring *) _Jv_AllocBytes (strhash_size * sizeof (jstring));
-      memset (strhash, 0, strhash_size * sizeof (jstring));
     }
   else
     {
@@ -133,7 +132,6 @@ rehash ()
       jstring* ptr = strhash + i;
       int nsize = strhash_size * 2;
       jstring *next = (jstring *) _Jv_AllocBytes (nsize * sizeof (jstring));
-      memset (next, 0, nsize * sizeof (jstring));
 
       while (--i >= 0)
 	{

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