optimize cpu_profile_transformer to not create intermediate lists (#8839)

Uses an iterator over the stack frame values in CpuProfileTransformer, instead of allocating new lists for they keys and values in the map, which are then read by index. I also removed the late/nullable fields in favor of local variables, since the state was never used outside of a single method call.

As far as I could tell the keys were never actually used except to look up values in the map, so I dropped that entirely. There was an extra lookup in the map and local variable which I am pretty certain wasn't needed.

This isn't directly related to any specific issue, I just noticed it as I was perusing through some of the code for the cpu profiler and figured I would send something out, to dip my toes in here :).

No tests were added, the behavior should be unchanged so hopefully existing tests should cover it.

I did also add a TODO because I noticed a piece of logic that was O(N^2) worst case here but I don't know enough about how large the N is expected to be or whether its a common path, and it would be more involved to fix.
1 file changed
tree: c6b0289e2dab8b7a355d625bf0ade45ec260cae5
  1. .github/
  2. .vscode/
  3. _markdown_images/
  4. case_study/
  5. docs/
  6. packages/
  7. third_party/
  8. tool/
  9. .gitattributes
  10. .gitignore
  11. analysis_options.yaml
  12. AUTHORS
  13. BETA_TESTING.md
  14. CODE_OF_CONDUCT.md
  15. CODEOWNERS
  16. CONTRIBUTING.md
  17. devtools_options.yaml
  18. DOCUMENTATION.md
  19. flutter-candidate.txt
  20. LICENSE
  21. pubspec.yaml
  22. README.md
  23. STYLE.md
  24. TESTING.md
  25. TRIAGE.md
README.md

Dart & Flutter DevTools

Build Status OpenSSF Scorecard

What is this?

Dart & Flutter DevTools is a suite of performance tools for Dart and Flutter.

Getting started

For documentation on installing and trying out DevTools, please see our docs.

Contributing and development

Contributions welcome! See our contributing page for an overview of how to build and contribute to the project.

Terms and Privacy

By using Dart DevTools, you agree to the Google Terms of Service. To understand how we use data collected from this service, see the Google Privacy Policy.