public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Reza Roboubi <reza@parvan.net>
Cc: gcc-help@gcc.gnu.org
Subject: Re: how is strcmp implemented so efficiently?
Date: Wed, 01 Oct 2008 00:58:00 -0000	[thread overview]
Message-ID: <m3od255dzv.fsf@google.com> (raw)
In-Reply-To: <48E2AAD2.4030504@parvan.net> (Reza Roboubi's message of "Tue\, 30 Sep 2008 15\:40\:18 -0700")

Reza Roboubi <reza@parvan.net> writes:

> I noticed that strcmp is extremely smart.  It knows when one parameter
> has constant length, determined at compile time.  In that case it
> reverts to an inline version of the x86 string commands.
>
> I looked into the headers and strcmp is defined as an extern(not inline.)
>
> How would I ever write such an efficient function?  Is it
> possible(even _with_ the use of asm?!)

The compiler automatically recognizes strcmp when compiling C/C++
code, among many other builtin functions.  See the docs for the
complete list.

Ian

      parent reply	other threads:[~2008-10-01  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 22:40 Reza Roboubi
2008-09-30 22:55 ` me22
2008-10-01  0:58 ` Ian Lance Taylor [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=m3od255dzv.fsf@google.com \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=reza@parvan.net \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).