On Sat, Feb 22, 2003 at 12:54:54AM +0900, MoonWolf wrote:
> 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

How about something like this:

    if (FIXNUM_P(val)) {
      count = FIX2INT(val);
      count++;
      st_insert(tbl, key, INT2FIX(count));
    } else {
      val = rb_funcall(val, id_succ, 0);
      st_insert(tbl, key, val);
    }

The extra test for Fixnum should make negligible difference, and then you
don't need two separate libraries.

Regards,

Brian.