nitg: move collect_types_cache to the GlobalCompiler
authorJean Privat <jean@pryen.org>
Wed, 22 Aug 2012 10:54:22 +0000 (06:54 -0400)
committerJean Privat <jean@pryen.org>
Wed, 22 Aug 2012 13:16:26 +0000 (09:16 -0400)
There is one GlobalCompilerVisitor per C function, therefore having
the cache here was stupid.

GlobalCompiler is a singleton and is better suited to manage the cache.

Signed-off-by: Jean Privat <jean@pryen.org>

src/global_compiler.nit

index 8d11ead..13a7b2d 100644 (file)
@@ -368,6 +368,8 @@ private class GlobalCompiler
                        self.extern_bodies.add(tryfile)
                end
        end
+
+       private var collect_types_cache: HashMap[MType, Array[MClassType]] = new HashMap[MType, Array[MClassType]]
 end
 
 redef class String
@@ -877,7 +879,7 @@ private class GlobalCompilerVisitor
                        var types = [mtype]
                        return types
                end
-               var cache = self.collect_types_cache
+               var cache = self.compiler.collect_types_cache
                if cache.has_key(mtype) then
                        return cache[mtype]
                end
@@ -891,8 +893,6 @@ private class GlobalCompilerVisitor
                return types
        end
 
-       private var collect_types_cache: HashMap[MType, Array[MClassType]] = new HashMap[MType, Array[MClassType]]
-
        fun resolve_for(mtype: MType, recv: RuntimeVariable): MType
        do
                if not mtype.need_anchor then return mtype