github/linguist — pull request #806 by charliesome (2013-12-03 04:56:23+00:00)
Title: Use JSON instead of YAML for loading samples.json

This pull request swaps out `YAML.load` for `JSON.load` in samples loading if JSON is available.

JSON is about 10x quicker than YAML:

```irb
>> Benchmark.measure { YAML.load(File.read("lib/linguist/samples.json")) }.to_s
=> " 0.690000 0.010000 0.700000 ( 0.691805)\n"
>> Benchmark.measure { JSON.load(File.read("lib/linguist/samples.json")) }.to_s
=> " 0.050000 0.000000 0.050000 ( 0.056488)\n"
```

On Ruby 1.8 where JSON is not in the stdlib, this will fall back to YAML if it can't require JSON.