perf: skip comment assignment when no comments exist (#1473)

In a large repo this made a _minor_ difference in memory consumption on
gazelle invocations. This is minor enough it may not be worth it, or
maybe only the first commit is worth the extra code.

The first commit is simpler and has the largest gain in my large repo,
but doesn't cover as wide of a range of cases.

Robot summary of results:
```
  ┌────────────────────────────────────────────────────┬───────────────┬─────────┐
  │                       build                        │ order() alloc │ vs base │
  ├────────────────────────────────────────────────────┼───────────────┼─────────┤
  │ base (no buildtools change)                        │ 137.6 MB      │ —       │
  ├────────────────────────────────────────────────────┼───────────────┼─────────┤
  │ commit 1 (guard: skip when no comments)            │ 60.7 MB       │ −56%    │
  ├────────────────────────────────────────────────────┼───────────────┼─────────┤
  │ commit 1 + 2 (guard + finer-grained split)         │ 42.1 MB       │ −69%    │
  └────────────────────────────────────────────────────┴───────────────┴─────────┘
```

## Buildtools PR checklist

- [x] The code in this PR is covered by unit/integration tests.
- [x] I have tested these changes and provide testing instructions
below.
- [x] I have either responded to, or resolved all Gemini comments on the
PR.
- [x] I have read Google Eng Practices on [Small
Changes](https://google.github.io/eng-practices/review/developer/small-cls.html),
this PR either follows these guidelines or the description provides
reasoning for why they can not be followed.

## Description

`assignComments` previously walked the full syntax tree on every parse,
building preorder and postorder node lists used to attach line and
suffix comments.

This change skips the walking and `pre/post` construction when no
comments exists.

### (optional) These changes were tested using the following steps

bazel tests, patching the go.mod when invoking gazelle in a large repo
while profiling memory/GC
1 file changed
tree: ff5b1a4463d4a8e0f88bf6502f6f9a50de93d333
  1. .bazelci/
  2. .github/
  3. api_proto/
  4. build/
  5. build_proto/
  6. buildifier/
  7. buildozer/
  8. bzlenv/
  9. config/
  10. convertast/
  11. deps_proto/
  12. differ/
  13. edit/
  14. extra_actions_base_proto/
  15. file/
  16. generatetables/
  17. labels/
  18. lang/
  19. release/
  20. tables/
  21. testutils/
  22. unused_deps/
  23. warn/
  24. wspace/
  25. .bazelrc
  26. .bazelversion
  27. .gitignore
  28. .mailmap
  29. .pre-commit-config.yaml
  30. BUILD.bazel
  31. CODEOWNERS
  32. CONTRIBUTING.md
  33. CONTRIBUTORS
  34. go.mod
  35. go.sum
  36. launcher.js
  37. LICENSE
  38. MODULE.bazel
  39. README.md
  40. status.py
  41. update_generated.sh
  42. WARNINGS.md
  43. WORKSPACE
  44. WORKSPACE.bzlmod
README.md

Buildtools for bazel

This repository contains developer tools for working with Google's bazel buildtool.

Build status

Setup

See instructions in each tool's directory.