[M] Change in fuchsia/fuchsia[main]: [rust] Optimize reading lines from files

0 views
Skip to first unread message

'Erick Tryzelaar (Gerrit)' via owners-override

unread,
Apr 15, 2026, 11:12:59 AM (5 days ago) Apr 15
to Owners Override
Attention needed from Mike Comfoltey and Owners Override

Erick Tryzelaar has uploaded the change for review

Erick Tryzelaar would like Owners Override to review this change.

Commit message

[rust] Optimize reading lines from files

`std::io::BufRead::lines` allocates a `String` for each line, which is
not necessary in most cases. Instead, you can use a `String` buffer with
`std::io::BufRead::read_line`, but that API can be a little clunky,
especially if you use `continue` to skip a row early.

This patch creates a helper library `buf-read-ext`, which has a
`lending_lines` method. This applies the "lending iterator" pattern to
make sure the buffer is cleared on every `next()` call.

Finally, this pattern is applied to a few places in-tree that was using
`BufRead::lines`.
Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d

Change diff


Change information

Files:
  • M src/developer/ffx/tools/playground/BUILD.gn
  • M src/developer/ffx/tools/playground/src/lib.rs
  • M src/lib/BUILD.gn
  • A src/lib/buf-read-ext/BUILD.gn
  • A src/lib/buf-read-ext/OWNERS
  • A src/lib/buf-read-ext/src/lib.rs
  • M src/lib/diagnostics/selectors/BUILD.gn
  • M src/lib/diagnostics/selectors/src/selectors.rs
  • M src/security/lib/scrutiny/utils/BUILD.gn
  • M src/security/lib/scrutiny/utils/src/golden.rs
  • M src/sys/pkg/lib/fuchsia-pkg/BUILD.gn
  • M src/sys/pkg/lib/fuchsia-pkg/src/meta_contents.rs
  • M src/sys/pkg/lib/fuchsia-pkg/src/package_build_manifest.rs
  • M src/sys/pkg/lib/package-tool/BUILD.gn
  • M src/sys/pkg/lib/package-tool/src/package_archive.rs
  • M src/sys/pkg/lib/system-image/BUILD.gn
  • M src/sys/pkg/lib/system-image/src/path_hash_mapping.rs
Change size: M
Delta: 17 files changed, 153 insertions(+), 37 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Mike Comfoltey
  • Owners Override
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Gerrit-Change-Number: 1572233
Gerrit-PatchSet: 8
Gerrit-Owner: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Aaron Wood <aaro...@google.com>
Gerrit-Reviewer: Ben Keller <galb...@google.com>
Gerrit-Reviewer: Casey Dahlin <sad...@google.com>
Gerrit-Reviewer: Clayton Mccray <clayto...@google.com>
Gerrit-Reviewer: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Mike Comfoltey <comf...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Mike Comfoltey <comf...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/ea5aa32c9f8dbf300af53734bc936170983941e6-HTML%40fuchsia-review.googlesource.com.
unsatisfied_requirement
satisfied_requirement
open
diffy

'Erick Tryzelaar (Gerrit)' via owners-override

unread,
Apr 15, 2026, 11:13:04 AM (5 days ago) Apr 15
to Owners Override, Clayton Mccray, Aaron Wood, Mike Comfoltey, Casey Dahlin, Ben Keller, global-integrat...@fuchsia-infra.iam.gserviceaccount.com, fuchsia-int...@luci-project-accounts.iam.gserviceaccount.com
Attention needed from Mike Comfoltey and Owners Override

Erick Tryzelaar voted and added 1 comment

Votes added by Erick Tryzelaar

Fuchsia-Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 8 (Latest):
Erick Tryzelaar . resolved

Adding owners-override to introduce a new library in src/lib to add extension methods to the rust trait `std::io::BufRead`.

Open in Gerrit

Related details

Attention is currently required from:
  • Mike Comfoltey
  • Owners Override
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Gerrit-Change-Number: 1572233
Gerrit-PatchSet: 8
Gerrit-Owner: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Aaron Wood <aaro...@google.com>
Gerrit-Reviewer: Ben Keller <galb...@google.com>
Gerrit-Reviewer: Casey Dahlin <sad...@google.com>
Gerrit-Reviewer: Clayton Mccray <clayto...@google.com>
Gerrit-Reviewer: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Mike Comfoltey <comf...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Mike Comfoltey <comf...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Comment-Date: Wed, 15 Apr 2026 15:12:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/ea5aa32c9f8dbf300af53734bc936170983941e6-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
unsatisfied_requirement
satisfied_requirement
open
diffy

'Adam Barth (Gerrit)' via owners-override

unread,
Apr 15, 2026, 11:27:50 AM (5 days ago) Apr 15
to Erick Tryzelaar, Owners Override, Clayton Mccray, Aaron Wood, Mike Comfoltey, Casey Dahlin, Ben Keller, global-integrat...@fuchsia-infra.iam.gserviceaccount.com, fuchsia-int...@luci-project-accounts.iam.gserviceaccount.com
Attention needed from Erick Tryzelaar, Mike Comfoltey and Owners Override

Adam Barth voted Owners-Override+1

Owners-Override+1
Open in Gerrit

Related details

Attention is currently required from:
  • Erick Tryzelaar
  • Mike Comfoltey
  • Owners Override
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Gerrit-Change-Number: 1572233
Gerrit-PatchSet: 8
Gerrit-Owner: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Aaron Wood <aaro...@google.com>
Gerrit-Reviewer: Adam Barth <aba...@google.com>
Gerrit-Reviewer: Ben Keller <galb...@google.com>
Gerrit-Reviewer: Casey Dahlin <sad...@google.com>
Gerrit-Reviewer: Clayton Mccray <clayto...@google.com>
Gerrit-Reviewer: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Mike Comfoltey <comf...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Mike Comfoltey <comf...@google.com>
Gerrit-Attention: Erick Tryzelaar <etryz...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Comment-Date: Wed, 15 Apr 2026 15:27:42 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/5a392efb57853cb9bd7c29e003ca0676617edc1b-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)' via owners-override

unread,
Apr 15, 2026, 1:04:08 PM (5 days ago) Apr 15
to Erick Tryzelaar, Adam Barth, Owners Override, Clayton Mccray, Aaron Wood, Mike Comfoltey, Casey Dahlin, Ben Keller, global-integrat...@fuchsia-infra.iam.gserviceaccount.com
Commit message:
[rust] Optimize reading lines from files

`std::io::BufRead::lines` allocates a `String` for each line, which is
not necessary in most cases. Instead, you can use a `String` buffer with
`std::io::BufRead::read_line`, but that API can be a little clunky,
especially if you use `continue` to skip a row early.

This patch creates a helper library `buf-read-ext`, which has a
`lending_lines` method. This applies the "lending iterator" pattern to
make sure the buffer is cleared on every `next()` call.

Finally, this pattern is applied to a few places in-tree that was using
`BufRead::lines`.
Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Reviewed-by: Clayton Mccray <clayto...@google.com>
Owners-Override: Adam Barth <aba...@google.com>
Commit-Queue: Erick Tryzelaar <etryz...@google.com>
Reviewed-by: Casey Dahlin <sad...@google.com>
Fuchsia-Auto-Submit: Erick Tryzelaar <etryz...@google.com>
Reviewed-by: Ben Keller <galb...@google.com>
Reviewed-by: Aaron Wood <aaro...@google.com>
Files:
  • M src/developer/ffx/tools/playground/BUILD.gn
  • M src/developer/ffx/tools/playground/src/lib.rs
  • M src/lib/BUILD.gn
  • A src/lib/buf-read-ext/BUILD.gn
  • A src/lib/buf-read-ext/OWNERS
  • A src/lib/buf-read-ext/src/lib.rs
  • M src/lib/diagnostics/selectors/BUILD.gn
  • M src/lib/diagnostics/selectors/src/selectors.rs
  • M src/security/lib/scrutiny/utils/BUILD.gn
  • M src/security/lib/scrutiny/utils/src/golden.rs
  • M src/sys/pkg/lib/fuchsia-pkg/BUILD.gn
  • M src/sys/pkg/lib/fuchsia-pkg/src/meta_contents.rs
  • M src/sys/pkg/lib/fuchsia-pkg/src/package_build_manifest.rs
  • M src/sys/pkg/lib/package-tool/BUILD.gn
  • M src/sys/pkg/lib/package-tool/src/package_archive.rs
  • M src/sys/pkg/lib/system-image/BUILD.gn
  • M src/sys/pkg/lib/system-image/src/path_hash_mapping.rs
Change size: M
Delta: 17 files changed, 153 insertions(+), 37 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Ben Keller, +2 by Clayton Mccray, +2 by Casey Dahlin, +2 by Aaron Wood
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Gerrit-Change-Number: 1572233
Gerrit-PatchSet: 9
Gerrit-Owner: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Aaron Wood <aaro...@google.com>
Gerrit-Reviewer: Adam Barth <aba...@google.com>
Gerrit-Reviewer: Ben Keller <galb...@google.com>
Gerrit-Reviewer: Casey Dahlin <sad...@google.com>
Gerrit-Reviewer: Clayton Mccray <clayto...@google.com>
Gerrit-Reviewer: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Mike Comfoltey <comf...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/b314e274fd6e36a540d3fbfdd929b1d609be24f0-HTML%40fuchsia-review.googlesource.com.
open
diffy
satisfied_requirement

'global-integration-ci-builder@fuchsia-infra.iam.gserviceaccount.com (Gerrit)' via owners-override

unread,
Apr 15, 2026, 1:13:06 PM (5 days ago) Apr 15
to Erick Tryzelaar, fuchsia-int...@luci-project-accounts.iam.gserviceaccount.com, Adam Barth, Owners Override, Clayton Mccray, Aaron Wood, Mike Comfoltey, Casey Dahlin, Ben Keller, global-integrat...@fuchsia-infra.iam.gserviceaccount.com

Message from global-integra...@fuchsia-infra.iam.gserviceaccount.com

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ic7176d7629a2dc414264c537adc3070b8a45a00d
Gerrit-Change-Number: 1572233
Gerrit-PatchSet: 9
Gerrit-Owner: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Aaron Wood <aaro...@google.com>
Gerrit-Reviewer: Adam Barth <aba...@google.com>
Gerrit-Reviewer: Ben Keller <galb...@google.com>
Gerrit-Reviewer: Casey Dahlin <sad...@google.com>
Gerrit-Reviewer: Clayton Mccray <clayto...@google.com>
Gerrit-Reviewer: Erick Tryzelaar <etryz...@google.com>
Gerrit-Reviewer: Mike Comfoltey <comf...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/f2600d3182b4edac2d21b00365e6c36b1dc11a65-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'Mike Comfoltey (Gerrit)' via owners-override

unread,
Apr 15, 2026, 1:53:17 PM (5 days ago) Apr 15
to fuchsia-int...@luci-project-accounts.iam.gserviceaccount.com, Erick Tryzelaar, global-integra...@fuchsia-infra.iam.gserviceaccount.com, Adam Barth, Owners Override, Clayton Mccray, Aaron Wood, Casey Dahlin, Ben Keller, global-integrat...@fuchsia-infra.iam.gserviceaccount.com

Mike Comfoltey voted Code-Review+2

Code-Review+2
Gerrit-Comment-Date: Wed, 15 Apr 2026 17:53:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/a1d4cea7ed755b3f2cba1cd8d392793566f417da-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages