joyent/node — pull request #3291 by FB55 (2012-05-20 20:01:57+00:00)
Title: Rearranged urlFormat

After spending five minutes figuring out what the `urlFormat` function does, I decided to open another pull request with a rearranged version (I don't want to write _rewritten_, as that would be too much). This time, the parts are processed in order and directly appended to the result string.

A quick [benchmark](https://gist.github.com/320e6a4558e969048e7a#file_new_url_format.js) showed the following results:

```
{ node: '0.6.17',
v8: '3.6.6.25',
ares: '1.7.5-DEV',
uv: '0.6',
openssl: '0.9.8r' }
Scores: (bigger is better)

new_format
Raw:
> 25.94810379241517
> 26.06177606177606
> 26.418786692759294
> 26.29016553067186
> 26.162790697674417
Average (mean) 26.17632455505936

old_format
Raw:
> 19.53125
> 20.937188434695912
> 20.833333333333332
> 20.854021847070506
> 20.792079207920793
Average (mean) 20.58957456460411

Winner: new_format
Compared with next highest (old_format), it's:
21.34% faster
1.27 times as fast
0.1 order(s) of magnitude faster
```