@@ -77,32 +77,17 @@ public static Expr Parse(ParserContext pcon, IPersistentMap form)
7777
7878 if ( form is IObj iobjForm && iobjForm . meta ( ) != null )
7979 return Compiler . OptionallyGenerateMetaInit ( pcon , form , ret ) ;
80- //else if (constant)
81- //{
82- // This 'optimzation' works, mostly, unless you have nested map values.
83- // The nested map values do not participate in the constants map, so you end up with the code to create the keys.
84- // Result: huge duplication of keyword creation. 3X increase in init time to the REPL.
85- // //IPersistentMap m = PersistentHashMap.EMPTY;
86- // //for (int i = 0; i < keyvals.length(); i += 2)
87- // // m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
88- // //return new ConstantExpr(m);
89- // return ret;
90- //}
9180 else if ( keysConstant )
9281 {
9382 // TBD: Add more detail to exception thrown below.
9483 if ( ! allConstantKeysUnique )
9584 throw new ArgumentException ( "Duplicate constant keys in map" ) ;
9685 if ( valsConstant )
9786 {
98- // This 'optimzation' works, mostly, unless you have nested map values.
99- // The nested map values do not participate in the constants map, so you end up with the code to create the keys.
100- // Result: huge duplication of keyword creation. 3X increase in init time to the REPL.
101- //IPersistentMap m = PersistentArrayMap.EMPTY;
102- //for (int i = 0; i < keyvals.length(); i += 2)
103- // m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
104- //return new ConstantExpr(m);
105- return ret ;
87+ IPersistentMap m = PersistentArrayMap . EMPTY ;
88+ for ( int i = 0 ; i < keyvals . length ( ) ; i += 2 )
89+ m = m . assoc ( ( ( LiteralExpr ) keyvals . nth ( i ) ) . Val , ( ( LiteralExpr ) keyvals . nth ( i + 1 ) ) . Val ) ;
90+ return new ConstantExpr ( m ) ;
10691 }
10792 else
10893 return ret ;
0 commit comments