fix for wordfreq for MLton
Stephen Weeks
sweeks@intertrust.com
Tue, 12 Jun 2001 23:16:50 -0700
--q3cOXNn2YU
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit
> I already E-mail'd Stephen, but he hasn't answered yet: the reason that
> wordfreq is so slow in MLton is because of a bug in the hash function used.
> I sent the fix to him, but if you just change the hash function so that it
> actually loops it will run MUCH better (currently it is only returning
> 26 different hash values, so the buckets are really big).
> Here is the fixed hash:
...
Thanks for the fix Henry (and for the other one you sent as well). Doug,
attached is the entire new version of wordfreq.mlton with both bug fixes. Of
course, there will probably be another one along shortly, since Henry and I are
looking into why it's still so slow.
--q3cOXNn2YU
Content-Type: application/octet-stream
Content-Disposition: attachment;
filename="wordfreq.mlton"
Content-Transfer-Encoding: base64
KCogLSotIG1vZGU6IHNtbCAtKi0KICogJElkOiB3b3JkZnJlcS5tbHRvbix2IDEuMSAyMDAxLzA2
LzAxIDE3OjU2OjMxIGRvdWcgRXhwICQKICogaHR0cDovL3d3dy5iYWdsZXkub3JnL35kb3VnL3No
b290b3V0LwogKiBmcm9tIFN0ZXBoZW4gV2Vla3MKICopCgpmdW4gZm9yIChzdGFydCwgc3RvcCwg
ZikgPQogICBsZXQKICAgICAgZnVuIGxvb3AgaSA9CgkgaWYgaSA+IHN0b3AKCSAgICB0aGVuICgp
CgkgZWxzZSAoZiBpOyBsb29wIChpICsgMSkpCiAgIGluCiAgICAgIGxvb3Agc3RhcnQKICAgZW5k
CmZ1biBpbmNyIHIgPSByIDo9IDEgKyAhcgp2YWwgc3ViID0gQXJyYXkuc3ViCnZhbCB1cGRhdGUg
PSBBcnJheS51cGRhdGUKICAgCnNpZ25hdHVyZSBIQVNIX1NFVCA9CiAgIHNpZwogICAgICB0eXBl
ICdhIHQKCiAgICAgIHZhbCBmb3JlYWNoOiAnYSB0ICogKCdhIC0+IHVuaXQpIC0+IHVuaXQKICAg
ICAgKCogbG9va3VwT3JJbnNlcnQgKHMsIGgsIH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