mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] string: implement streq()
Date: Tue, 4 Apr 2023 17:54:51 +0300	[thread overview]
Message-ID: <db6ce106-a5fc-4742-a59e-ccbd39dfd69d@p183> (raw)
In-Reply-To: <20230403141641.6ace0d85fd48fbed5c02d7ef@linux-foundation.org>

On Mon, Apr 03, 2023 at 02:16:41PM -0700, Andrew Morton wrote:
> On Sat, 1 Apr 2023 20:48:05 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 
> > Most of the time strcmp() is being used, strings are checked for equality.
> > Add wrapper to relay such intent (it is shorter to type, too).
> > 
> > Use
> > 	if (streq(s, "s")) {
> > 	}
> > or
> > 	if (!streq(s, "s")) {
> > 	}
> 
> Gee, do we really want this?  I mean, we all know how strcmp() works,
> don't we?
> 
> I'm thinking it would be better to remove the various cute little
> streq() macros and open-code strcmp(...)==0.

No! It's cool, trust me. Try it out, you'll like it.
We "know" how strcmp() works because C didn't have streq() from
the very beginning.

strcmp() is only for insertion into trees. Half of the time you need
to read to the end of the expression to know if it is check for equality
or inequality. With streq(), you don't.

	stralexey

  reply	other threads:[~2023-04-04 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 17:48 Alexey Dobriyan
2023-04-03 21:16 ` Andrew Morton
2023-04-04 14:54   ` Alexey Dobriyan [this message]
2023-04-05 10:45     ` David Laight
2023-04-05 11:39       ` Alexey Dobriyan

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=db6ce106-a5fc-4742-a59e-ccbd39dfd69d@p183 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®