This adds an optimized comparator generator for when all of the arguments are literals or simple (non-multi) symbols (which almost certainly means a simple lexenv lookup). In this version, don't bother wrapping any of the comparison values in an anonymous function since evaluation of the args is idempotent.
This is actually a targeted fix for reducing the memory usage of char-starter?; I'm trying to run Fennel in a low-memory environment (<= 4MB) and when I tried profiling require("fennel") with https://github.com/pmusa/lmprof to see where I could find some optimization opportunities, this was one of the indicated hotspots. Creating and immediately throwing away anonymous functions is not super great for memory use, and I noticed that this was a compiler enhancement opportunity: recognize when you have idempotent values and elide the function.
I ran the tests and they still pass. I'm 99% confident that this won't break other code; I was pretty simplistic and conservative about what values were considered idempotent, but my understanding might be flawed or incomplete.
This adds an optimized comparator generator for when all of the arguments are literals or simple (non-multi) symbols (which almost certainly means a simple lexenv lookup). In this version, don't bother wrapping any of the comparison values in an anonymous function since evaluation of the args is idempotent.
This is actually a targeted fix for reducing the memory usage of char-starter?; I'm trying to run Fennel in a low-memory environment (<= 4MB) and when I tried profiling
require("fennel")
with https://github.com/pmusa/lmprof to see where I could find some optimization opportunities, this was one of the indicated hotspots. Creating and immediately throwing away anonymous functions is not super great for memory use, and I noticed that this was a compiler enhancement opportunity: recognize when you have idempotent values and elide the function.I ran the tests and they still pass. I'm 99% confident that this won't break other code; I was pretty simplistic and conservative about what values were considered idempotent, but my understanding might be flawed or incomplete.