kframework/k — pull request #537 by yilongli (2014-06-01 23:11:28+00:00)
Title: Cleanup builtin map api

@andreistefanescu @dwightguth please review.

1) Use builder pattern to avoid unnecessary defensive-copying in both the ```transform``` methods and ```BuiltinMap``` constructors;
2) Make ```BuiltinMap``` immutable.

P.S.
I made a stupid mistake in profiling the rewrite engine when I tried to use persistent map for ```BuiltinMap``` in https://github.com/kframework/k/pull/531. The performance is actually worse (5~10% slower) since there are usually a lots of lookups and very few updates. The speedup of update by persistent data structure doesn't out-weigh the slowdown of lookup (even with reasonably large ```store``` cell). Therefore, the use of persistent data structure only makes sense for ```KSequence``` and, maybe, ```KList```, whose structures change very frequently.