mrdoob/three.js — pull request #3409 by bhouston (2013-04-30 14:39:51+00:00)
Title: 2x faster Geometry.mergeVertices()

In my profiling I found that ```Geometry.mergeVertices()``` was a major bottleneck. I was able to narrow down the performance issue to a single line:

```javascript
key = [ Math.round( v.x * precision ), Math.round( v.y * precision ),
Math.round( v.z * precision ) ].join( '_' );
```

I have replaced that line with this:

```javascript
key = (( v.x * precision ) | 0 ) + '_' + (( v.y * precision ) | 0 ) +
'_' + (( v.z * precision ) | 0 );
```

According to jsperf, this new version is 84% faster than the previous version:

http://jsperf.com/mergevertices-core

The new version avoids creating an array, it uses bitwise truncation (limiting vertices positions to be less than +/-2,000,000 in range), and also uses inline string concatenation rather than ```.join()```.

This results in an overall speed up of ```Geometry.mergeVertices()```of 2x in my larger scale profiling results.