caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alexandre Pilkiewicz <alexandre.pilkiewicz@polytechnique.org>
To: Arlen Cuss <celtic@sairyx.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Hashtbl: find and find_rec
Date: Mon, 7 Mar 2011 13:00:20 +0100	[thread overview]
Message-ID: <AANLkTimLN9aqxvBwCmRbrxc98nCxDuN-wMaLqMmJy8qE@mail.gmail.com> (raw)
In-Reply-To: <1299479990.22876.15.camel@azayaka>

Hi

2011/3/7 Arlen Cuss <celtic@sairyx.org>:
> Hi all,
>
> I'm puzzling over the OCaml source, and am trying to work out the reason
> for the following definition:

[snip]

> My only guess thus far is that it's cheaper if we don't recurse (stack
> doesn't grow as much, fewer branches), and thus a few levels of testing
> are put in for good measure to speed up the case where it's one of the
> first three items.
>
> Is this it? Or am I missing something else?

I don't think stack is smaller since the find_rec function is tail
recursive. So it is basically loop unrolling (fewer branches).

What I don't really understand is why only do the unrolling on the 3
first iterations. As soon as we have an unrolled version, why not
calling it recursively?

      reply	other threads:[~2011-03-07 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-07  6:39 Arlen Cuss
2011-03-07 12:00 ` Alexandre Pilkiewicz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimLN9aqxvBwCmRbrxc98nCxDuN-wMaLqMmJy8qE@mail.gmail.com \
    --to=alexandre.pilkiewicz@polytechnique.org \
    --cc=caml-list@inria.fr \
    --cc=celtic@sairyx.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).