Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Identified and fixed several algorithmic and memory allocation bottlenecks causing poor performance in list operations, database queries, and UI rendering.

Changes

Nested loop elimination (O(n²) → O(n))

  • AdapterRule: Use HashMap for related package lookups instead of nested iteration
  • BlocklistManager: Use HashSet for orphaned file detection instead of nested loops

String concatenation in hot paths

  • DatabaseHelper: Replace += with StringBuilder in 11 SQL query building methods
  • Eliminates intermediate String object creation on every append

Repeated sorting in UI rendering

  • Tracker: Add lazy-initialized sorted hosts cache
  • TrackersListAdapter: Use cached sort instead of allocating + sorting ArrayList on every bind

Example

Before (line 1043-1056 in AdapterRule):

for (String pkg : rule.related) {
    for (Rule related : listAll)
        if (related.packageName.equals(pkg)) {
            // update related rule
        }
}

After:

HashMap<String, Rule> packageMap = new HashMap<>();
for (Rule r : listAll) packageMap.put(r.packageName, r);
for (String pkg : rule.related) {
    Rule related = packageMap.get(pkg);
    if (related != null) { /* update */ }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx4608m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Identify and suggest improvements to slow or inefficient code


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 10, 2026 13:39
Co-authored-by: kasnder <5175206+kasnder@users.noreply.github.com>
Co-authored-by: kasnder <5175206+kasnder@users.noreply.github.com>
Copilot AI changed the title [WIP] Identify and suggest improvements to slow code Optimize nested loops, string concatenation, and repeated sorting Jan 10, 2026
Copilot AI requested a review from kasnder January 10, 2026 13:45
@kasnder
Copy link
Member

kasnder commented Jan 10, 2026

What's the expected speed up of this? Appears rather minimal?

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.

2 participants