amber-smalltalk/amber — pull request #789 by herby (2013-12-24 03:28:10+00:00)
Title: Set speedup

Complete redesigning of `Set`.

An element added/removed/searched is examined for its type (`typeof` of `x.valueOf()`) and if it is one of the primitive types, it is stored in dedicated container as JS property key.

In case it is the true object, `x.constructor.name` is looked up (or `''` if cannot be found), and element is stored in an Array bucket related to to the constructor name.

In the worst case (all elements true objects of the same kind), like

```smalltalk
| x |
x := Set new.
Smalltalk current classes do: [ :each | x addAll: each methods ].
```

the time added is negligible (10 500 ms with old `Set`, 10 900 ms with new one).

OTOH, with `(Smalltalk current at: 'allSelectors') value asSet`, the difference is really big: 900 ms versus 21 ms.

All tests work. IE8 works.