NicolasPetton/amber — pull request #175 by herby (2012-04-23 16:21:55+00:00)
Title: Optimization: performance of critical functions according to Chrome profiler

(not that I am performance freak, but it was too slow to bug me enough, so I started a profiler and began to play)

All changes were profiled by committing the same package (one I work on, very small for the moment) and editing `Browser >> commitPackage` to start and stop the profiling (no "mouse click as soon as I see it stopped)

List of changes:
- `=== undefined || === null` => `== null` (does the same thing and seem to be optimized by browsers)
- restructuring of ifs in `send` functions
- refactoring `pushContext` / `popContext` machinery to be faster (lot of it simply inlined)
- only using one field for context pooling (very suprisingly, gc went down from 60ms to 5ms with this - maybe because less old objects are held in old context pool; FYI without any pooling at all, gc is up at 50ms again)
- making new context is much more lightweight (no `that.f = function () ...`, using `prototype`, and after previous steps, only `copy` was left, anyway, but it should not bother the instantiation)

As a consequence of these changes, the total time of `withContextSend` (the winner of time spent) went down from 15+ seconds to 7+.