2008-11-28 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / reflection.c
index 23ccc85b8de6a26e6570052d82851040aafb39bc..09903644eda911f6ff7caaa00febe1d200abe71b 100644 (file)
@@ -6037,6 +6037,10 @@ mono_type_get_object (MonoDomain *domain, MonoType *type)
         */
        type = klass->byval_arg.byref == type->byref ? &klass->byval_arg : &klass->this_arg;
 
+       /* void is very common */
+       if (type->type == MONO_TYPE_VOID && domain->typeof_void)
+               return (MonoReflectionType*)domain->typeof_void;
+
        /*
         * If the vtable of the given class was already created, we can use
         * the MonoType from there and avoid all locking and hash table lookups.
@@ -6088,6 +6092,10 @@ mono_type_get_object (MonoDomain *domain, MonoType *type)
 #endif
        res->type = type;
        mono_g_hash_table_insert (domain->type_hash, type, res);
+
+       if (type->type == MONO_TYPE_VOID)
+               MONO_OBJECT_SETREF (domain, typeof_void, res);
+
        mono_domain_unlock (domain);
        return res;
 }
@@ -6741,6 +6749,8 @@ _mono_reflection_parse_type (char *name, char **endptr, gboolean is_recursed,
 
        /* last_point separates the namespace from the name */
        last_point = NULL;
+       /* Skips spaces */
+       while (*p == ' ') p++, start++, w++, name++;
 
        while (*p) {
                switch (*p) {