]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.codegen.fixup: cache symbol names, reducing image size by ~200Kb
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 Jan 2010 10:18:43 +0000 (23:18 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 Jan 2010 10:18:43 +0000 (23:18 +1300)
basis/compiler/codegen/fixup/fixup.factor

index dbe7c864a5a93613e378803f7fef465b8a5a1d41..efdc02cc1fa962fa0285a8f754cd0e5a551a15ca 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays byte-arrays byte-vectors generic assocs hashtables
 io.binary kernel kernel.private math namespaces make sequences
 words quotations strings alien.accessors alien.strings layouts
 system combinators math.bitwise math.order generalizations
-accessors growable fry compiler.constants ;
+accessors growable fry compiler.constants memoize ;
 IN: compiler.codegen.fixup
 
 ! Owner
@@ -52,8 +52,11 @@ SYMBOL: relocation-table
 : rel-fixup ( class type -- )
     swap compiled-offset add-relocation-entry ;
 
+! Caching common symbol names reduces image size a bit
+MEMO: cached-string>symbol ( symbol -- obj ) string>symbol ;
+
 : add-dlsym-parameters ( symbol dll -- )
-    [ string>symbol add-parameter ] [ add-parameter ] bi* ;
+    [ cached-string>symbol add-parameter ] [ add-parameter ] bi* ;
 
 : rel-dlsym ( name dll class -- )
     [ add-dlsym-parameters ] dip rt-dlsym rel-fixup ;