Skip to content

Refactor MethodSignature to delay expensive calculations.#5171

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_916099675
Open

Refactor MethodSignature to delay expensive calculations.#5171
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_916099675

Conversation

@copybara-service
Copy link
Copy Markdown

Refactor MethodSignature to delay expensive calculations.

Calculating XMethodElement.parameters() can be expensive because it triggers KSP's Analysis API to resolve parameter types. This CL restructures MethodSignature to delay calling XMethodElement.parameters() until it's actually needed.

The main changes are:

  • hashCode() now only looks at the method name. For Set and Map insertions, equals() will only be called when there's a name collision.
  • equals() short-circuits if the name() is not equal, so it avoids computing the lazy parameters() in most cases.

RELNOTES=N/A

Calculating `XMethodElement.parameters()` can be expensive because it triggers KSP's Analysis API to resolve parameter types. This CL restructures `MethodSignature` to delay calling `XMethodElement.parameters()` until it's actually needed.

The main changes are:

  * `hashCode()` now only looks at the method name. For Set and Map insertions, `equals()` will only be called when there's a name collision.
  * `equals()` short-circuits if the `name()` is not equal, so it avoids computing the lazy `parameters()` in most cases.

RELNOTES=N/A
PiperOrigin-RevId: 916099675
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant