--------_3E56479AED4F017A0008_MULTIPART_MIXED_
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

> Nice. Perhaps could be made more general by checking if the value is a
> Fixnum first? (And if not, it could do h[x]  [x].succ)

generic version 'hashsuccg.c' here.

 $ ruby -r mkmf -e'create_makefile("hashsuccg")'
 $ make
 # make install

Usage:
 require "hashsuccg"
 h  ash.new("a")
 h.succ! "foo"   # {"foo"b"}
 h.succ! "foo"   # {"foo"c"}

Benchmark:
$ time ruby b_hashsucc.rb  # original hashsucc.c
ruby b_hashsucc.rb  5.04s user 0.01s system 100% cpu 5.048 total
$ time ruby b_hashsuccg.b  # generic version
ruby b_hashsuccg.rb  6.23s user 0.01s system 100% cpu 6.236 total

'hashsucc.c' bug-fix version attached.

-- 
MoonWolf <moonwolf / moonwolf.com>

--------_3E56479AED4F017A0008_MULTIPART_MIXED_
Content-Type: application/octet-stream; name="hashsucc.c"
Content-Disposition: attachment;
 filenameashsucc.c"
Content-Transfer-Encoding: base64

I2luY2x1ZGUgInJ1YnkuaCIKI2luY2x1ZGUgInN0LmgiCgpWQUxVRQpoYXNoX3N1Y2MoaGFzaCwg
a2V5KQogICAgVkFMVUUgaGFzaCwga2V5Owp7CiAgVkFMVUUgYXJ5LCB2YWwsIG9uZTsKICBzdF90
YWJsZSAqdGJsOwogIGludCBsZW5ndGgsIGNvdW50LCBvZnM7CiAgCiAgb25lID0gSU5UMkZJWCgx
KTsKICB0YmwgPSBSSEFTSChoYXNoKS0+dGJsOwogIAogIHN3aXRjaChUWVBFKGtleSkpIHsKICBj
YXNlIFRfU1RSSU5HOgogICAgaWYgKHN0X2xvb2t1cCh0YmwsIGtleSwgJnZhbCkpIHsKICAgICAg
Y291bnQgPSBGSVgySU5UKHZhbCk7CiAgICAgIGNvdW50Kys7CiAgICAgIHN0X2luc2VydCh0Ymws
IGtleSwgSU5UMkZJWChjb3VudCkpOwogICAgfSBlbHNlIHsKICAgICAgc3RfYWRkX2RpcmVjdCh0
YmwsIHJiX3N0cl9uZXc0KGtleSksIG9uZSk7CiAgICB9CiAgICBicmVhazsKICBjYXNlIFRfQVJS
QVk6CiAgICBhcnkgPSBrZXk7CiAgICBsZW5ndGggPSBSQVJSQVkoYXJ5KS0+bGVuOwogICAgZm9y
KG9mcz0wOyBvZnMgPCBsZW5ndGg7IG9mcysrKSB7CiAgICAgIGtleSA9IFJBUlJBWShhcnkpLT5w
dHJbb2ZzXTsKICAgICAgaWYgKHN0X2xvb2t1cCh0YmwsIGtleSwgJnZhbCkpIHsKICAgICAgICBj
b3VudCA9IEZJWDJJTlQodmFsKTsKICAgICAgICBjb3VudCsrOwogICAgICAgIHN0X2luc2VydCh0
YmwsIGtleSwgSU5UMkZJWChjb3VudCkpOwogICAgICB9IGVsc2UgewogICAgICAgIHN0X2FkZF9k
aXJlY3QodGJsLCByYl9zdHJfbmV3NChrZXkpLCBvbmUpOwogICAgICB9CiAgICB9CiAgICBicmVh
azsKICB9CiAgcmV0dXJuIGhhc2g7Cn0KCnZvaWQKSW5pdF9oYXNoc3VjYygpCnsKICByYl9kZWZp
bmVfbWV0aG9kKHJiX2NIYXNoLCJzdWNjISIsIGhhc2hfc3VjYywgMSk7Cn0K

--------_3E56479AED4F017A0008_MULTIPART_MIXED_
Content-Type: application/octet-stream; name="hashsuccg.c"
Content-Disposition: attachment;
 filenameashsuccg.c"
Content-Transfer-Encoding: base64

I2luY2x1ZGUgInJ1YnkuaCIKI2luY2x1ZGUgInN0LmgiCgpzdGF0aWMgSUQgaWRfc3VjYywgaWRf
ZGVmYXVsdDsKCgpWQUxVRQpoYXNoX3N1Y2MoaGFzaCwga2V5KQogICAgVkFMVUUgaGFzaCwga2V5
Owp7CiAgVkFMVUUgYXJ5LCB2YWw7CiAgc3RfdGFibGUgKnRibDsKICBpbnQgbGVuZ3RoLCBjb3Vu
dCwgb2ZzOwogIAogIHRibCA9IFJIQVNIKGhhc2gpLT50Ymw7CiAgCiAgc3dpdGNoKFRZUEUoa2V5
KSkg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