leereilly/swot — pull request #28 by johnotander (2013-05-24 15:46:15+00:00)
Title: Change academic_tld data structure from array to hash.

I created the gist, , to illustrate the performance boost with the data structure change from an array to a hash.

```
john-bigmac~/code/swot>array_to_hash:% ruby ../swot_performance/performance_test.rb 1000
For the Hash:
0.070000 0.000000 0.070000 ( 0.075911)
For the Array:
0.800000 0.010000 0.810000 ( 0.809945)
```

Granted a linear search for a match in an array as small as `ACADEMIC_TLDS` isn't exactly time consuming or resource intensive, however, it seems a constant-time key lookup is more appropriate. This way it's O(1) rather than O(n), this is especially important for lookups that don't exist in `ACADEMIC_TLDS`.

I didn't add any tests because the passing test suite seemed to reaffirm that the change didn't break anything. If you'd like me to add more tests as verification please let me know.