Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Pass std::string_view by value not by ref #33699

Merged
merged 1 commit into from
May 31, 2022

Conversation

cbracken
Copy link
Member

String views are small, cheap objects that fit in a couple registers, so
passing by value avoids pointer indirection and thus a memory load.

Fun related reading for future archaeologists:
https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/

And a Windows-specific footnote:
https://quuxplusone.github.io/blog/2021/11/19/string-view-by-value-ps/

No test change since there is no semantic change.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

String views are small, cheap objects that fit in a couple registers, so
passing by value avoids pointer indirection and thus a memory load.

Fun related reading for future archaeologists:
https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/

And a Windows-specific footnote:
https://quuxplusone.github.io/blog/2021/11/19/string-view-by-value-ps/

No test change since there is no semantic change.
@cbracken cbracken requested a review from chinmaygarde May 31, 2022 00:21
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Hixie
Copy link
Contributor

Hixie commented May 31, 2022

test-exempt: refactor with no semantic change

@cbracken cbracken merged commit 56e0c34 into flutter:main May 31, 2022
@cbracken cbracken deleted the stringview-by-value branch May 31, 2022 18:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 31, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
String views are small, cheap objects that fit in a couple registers, so
passing by value avoids pointer indirection and thus a memory load.

Fun related reading for future archaeologists:
https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/

And a Windows-specific footnote:
https://quuxplusone.github.io/blog/2021/11/19/string-view-by-value-ps/

No test change since there is no semantic change.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants