Skip to content

perf: switch wildcard dedup to O(1) set-based approach#50

Merged
NassimBtk merged 3 commits intofeature/issue-48-support-iterating-over-object-children-using-wildcardfrom
copilot/sub-pr-49
Mar 20, 2026
Merged

perf: switch wildcard dedup to O(1) set-based approach#50
NassimBtk merged 3 commits intofeature/issue-48-support-iterating-over-object-children-using-wildcardfrom
copilot/sub-pr-49

Conversation

Copy link

Copilot AI commented Mar 19, 2026

The wildcard expansion path in JFlat.java deduplicated child paths via a nested linear scan over newEntries, making it O(K²) per wildcard segment.

Changes

  • Replaced the inner for-loop dedup with a HashSet<String> seenLowercasePaths declared alongside newEntries
  • Dedup is now O(1) per candidate: seenLowercasePaths.add(childPath.toLowerCase()) returns false on collision, gating the newEntries.add() call
  • Added java.util.HashSet and java.util.Set imports
// Before — O(K²): scans newEntries linearly for every candidate
boolean alreadyAdded = false;
for (String added : newEntries) {
    if (added.equalsIgnoreCase(childPath)) { alreadyAdded = true; break; }
}
if (!alreadyAdded) newEntries.add(childPath);

// After — O(1): HashSet lookup on lowercase key
if (seenLowercasePaths.add(childPath.toLowerCase())) {
    newEntries.add(childPath);
}

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

… lookup

Co-authored-by: NassimBtk <14110109+NassimBtk@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 19, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-3f672d5de33c41b7/dbs/java/working/files-to-index13464155740327611490.list --sourceArchiveDir=/tmp/codeql-scratch-3f672d5de33c41b7/dbs/java/src --outputDir=/tmp/codeql-scratch-3f672d5de33c41b7/dbs/java/trap/java (dns block)

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

Copilot AI changed the title [WIP] [WIP] Addressing feedback on wildcard iterations: switch to set-based approach perf: switch wildcard dedup to O(1) set-based approach Mar 19, 2026
Copilot AI requested a review from NassimBtk March 19, 2026 20:46
@NassimBtk NassimBtk marked this pull request as ready for review March 20, 2026 10:04
@NassimBtk NassimBtk merged commit 63d88fb into feature/issue-48-support-iterating-over-object-children-using-wildcard Mar 20, 2026
@NassimBtk NassimBtk deleted the copilot/sub-pr-49 branch March 20, 2026 10:04
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