Skip to content

[gui] Improve Code Search Performance by Avoiding Exact Node Resolution #2439

@eybisi

Description

@eybisi

Issue details

Issue

Jadx currently finds the exact node location for code searches. This significantly slows down search performance when retrieving a large number of results, especially for common text searches.

Image

Optimization Proposal

When opening a new tab in the search results, getEnclosingNode is used to create a CodeNode in the search dialog. However, since the item's position is already known, resolving the exact node location is unnecessary. Instead, we can use the class node of the found text directly:

Current code (slow search):

JNode enclosingNode = getOrElse(getEnclosingNode(javaClass, end), rootCls);

Proposed change (instant search):

JNode enclosingNode = convert(wrapper.getJavaNodeByRef(javaClass.getCodeNodeRef()));

Results

With this change, search performance improves significantly(instant). I have tested this modification, clicking on search results correctly jumps to the expected location in Jadx without the additional overhead of exact node resolution.

Jadx version

dev

Java version

21.0.5

OS

  • Windows
  • Linux
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions