From: Matthew Wilcox <willy@infradead.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: alternative to xa_for_each?
Date: Wed, 1 Jul 2020 15:37:33 +0100 [thread overview]
Message-ID: <20200701143733.GR25523@casper.infradead.org> (raw)
In-Reply-To: <20200701060239.GA27121@infradead.org>
On Wed, Jul 01, 2020 at 07:02:39AM +0100, Christoph Hellwig wrote:
> Hi Matthew,
>
> I'm just reviewing a patch adding an xarray user, and I'm wondering
> if we could just replace xa_for_each with a loop on
> xa_find_after with a magic index to start from the beginning? That
> would always seem like more readable code than the magic looping macro.
The problem is that there is no index we can use for that purpose.
xa_find_after(0) should return the entry at 1 (or higher).
xa_find_after(ULONG_MAX) should return NULL. The xas_ version doesn't
have this problem because we can distinguish between "first time" and
"subsequent time" by values in the xa_state.
> And while we're at it: is there an idiomatic way to get the entry with
> the highest index?
That's something I need to add. I think I did it once but then the user
went away.
prev parent reply other threads:[~2020-07-01 14:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 6:02 Christoph Hellwig
2020-07-01 14:37 ` Matthew Wilcox [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=20200701143733.GR25523@casper.infradead.org \
--to=willy@infradead.org \
--cc=hch@infradead.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®