Fri May 10 18:14:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Fri, 10 May 2002 12:27:33 +0000 (12:27 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Fri, 10 May 2002 12:27:33 +0000 (12:27 -0000)
* reflection.c: sort methodsemantics table.

svn path=/trunk/mono/; revision=4483

mono/metadata/ChangeLog
mono/metadata/reflection.c

index 3f0ec8debf15f54f33e443083d84b729b6db6e65..591ae158cec5606addb87fe1e1fc18262c8dde6e 100644 (file)
@@ -1,4 +1,8 @@
 
+Fri May 10 18:14:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+       * reflection.c: sort methodsemantics table.
+
 Fri May 10 16:31:49 CEST 2002 Paolo Molaro <lupus@ximian.com>
 
        * reflection.h, reflection.c: honour init locals setting.
index f098677fd9e92f08f74a561aa8b6769fa5f639d4..2a795b7aabe264dbc58e3b01e0a7328e856c3aa1 100644 (file)
@@ -1406,6 +1406,19 @@ mono_image_fill_module_table (MonoDomain *domain, MonoReflectionModuleBuilder *m
                        (p) += 4 - (__diff & 3);\
        } while (0)
 
+static int
+compare_semantics (const void *a, const void *b)
+{
+       const guint32 *a_values = a;
+       const guint32 *b_values = b;
+       int assoc = a_values [MONO_METHOD_SEMA_ASSOCIATION] - b_values [MONO_METHOD_SEMA_ASSOCIATION];
+       if (assoc)
+               return assoc;
+       return a_values [MONO_METHOD_SEMA_SEMANTICS] - b_values [MONO_METHOD_SEMA_SEMANTICS];
+
+       
+}
+
 /*
  * build_compressed_metadata() fills in the blob of data that represents the 
  * raw metadata as it will be saved in the PE file. The five streams are output 
@@ -1415,6 +1428,7 @@ mono_image_fill_module_table (MonoDomain *domain, MonoReflectionModuleBuilder *m
 static void
 build_compressed_metadata (MonoDynamicAssembly *assembly)
 {
+       MonoDynamicTable *table;
        int i;
        guint64 valid_mask = 0;
        guint64 sorted_mask;
@@ -1544,6 +1558,12 @@ build_compressed_metadata (MonoDynamicAssembly *assembly)
                *int32val++ = meta->tables [i].rows;
        }
        p = (unsigned char*)int32val;
+
+       /* sort the tables that still need sorting */
+       table = &assembly->tables [MONO_TABLE_METHODSEMANTICS];
+       if (table->rows)
+               qsort (table->values + MONO_METHOD_SEMA_SIZE, table->rows, sizeof (guint32) * MONO_METHOD_SEMA_SIZE, compare_semantics);
+
        /* compress the tables */
        for (i = 0; i < 64; i++){
                int row, col;