From: "Uwe Kleine-König" <uwe@kleine-koenig.org>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] scripts/make_fit: factor dtb file name into configuration name
Date: Tue, 18 Mar 2025 12:33:30 +0100 [thread overview]
Message-ID: <7gm47as3wubmlxwg3o64zh2w4sgi3zwzpog5z6vuxdhctykks4@nrpltcjzdcsk> (raw)
In-Reply-To: <a3235700-b02b-4870-ba19-b401d6e36600@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]
Hello,
On Tue, Mar 18, 2025 at 12:27:26PM +0100, Ahmad Fatoum wrote:
> Hello Uwe,
>
> On 3/18/25 12:03, Uwe Kleine-König wrote:
> > On Tue, Mar 18, 2025 at 09:25:04AM +0100, Ahmad Fatoum wrote:
> >> fsw.end_node()
> >> - seq = 0
> >> with fsw.add_node('configurations'):
> >> - for model, compat, files in entries:
> >> - seq += 1
> >> - with fsw.add_node(f'conf-{seq}'):
> >> + for dtbname, model, compat, files in entries:
> >> + with fsw.add_node(f'conf-{dtbname}'):
> >
> > Funny/surprising semantic of fsw.add_node (i.e. fsw refers to the new
> > node in the with-body?)
>
> Yes. I suspect it's to ensure that a node end tag is inserted
> after the properties.
>
> >> - entries.append([model, compat, files_seq])
> >> + dtbname = os.path.basename(fname)
> >> + ndtbs_seen = len(dtbs_seen)
> >> + dtbs_seen.add(dtbname)
> >> + if len(dtbs_seen) == ndtbs_seen:
> >> + raise RuntimeError(f"Duplicate file name '{dtbname}' during FIT creation")
> >> +
> >> + entries.append([dtbname, model, compat, files_seq])
> >
> > dtbname = os.path.basename(fname)
> > if dtbname in dtbs_seen:
> > raise RuntimeError(...)
> > dtbs_seen.add(dtbname)
> > entries.append(...)
> >
> > looks more pythonic (to me).
>
> I dislike iterating twice over the dtbs. I wrote it this way,
> because I assumed calling len on the set is O(1).
I would expect that both `dtbname in dtbs_seen` and
`dtbs_seen.add(dtbname)` is O(1) (in the absense of hash collisions).
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-03-18 11:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 8:25 Ahmad Fatoum
2025-03-18 8:25 ` [PATCH 2/4] amba: drop unused hepers for creating AMBA devices outside OF Ahmad Fatoum
2025-03-18 10:53 ` Uwe Kleine-König
2025-03-18 8:25 ` [PATCH 3/4] amba: support masking data abort during identification Ahmad Fatoum
2025-03-18 11:04 ` Sascha Hauer
2025-03-18 11:24 ` Ahmad Fatoum
2025-03-18 8:25 ` [PATCH 4/4] ARM: qemu: mask data aborts during AMBA identification Ahmad Fatoum
2025-03-18 11:07 ` Sascha Hauer
2025-03-18 11:03 ` [PATCH 1/4] scripts/make_fit: factor dtb file name into configuration name Uwe Kleine-König
2025-03-18 11:27 ` Ahmad Fatoum
2025-03-18 11:33 ` Uwe Kleine-König [this message]
2025-03-18 11:07 ` Sascha Hauer
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=7gm47as3wubmlxwg3o64zh2w4sgi3zwzpog5z6vuxdhctykks4@nrpltcjzdcsk \
--to=uwe@kleine-koenig.org \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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