Skip to content

Don't handle every array item within each array item #4480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2023

Conversation

candrews
Copy link
Contributor

In handleArray, the array v is looped over. For each item, the entire array is looped over again, resulting in an array v of length n resulting in an output array of length n^2, making handleArray's complexity O(n^2).

However, that n^2 looping is unnecessary. Removing it brings the complexity of handleArray down to O(n), drastically reducing execution time.

In handleArray, the array v is looped over. For each item, the entire
array is looped over again, resulting in an array v of length n
resulting in an output array of length n^2, making handleArray's
complexity O(n^2).

However, that n^2 looping is unnecessary. Removing it brings the
complexity of handleArray down to O(n), drastically reducing execution
time.
@candrews
Copy link
Contributor Author

@Amndeep7 as discussed, I discovered this problem while working on #4255 but since it's unrelated to that effort I've created a new PR for this change.

Amndeep7 added 2 commits May 23, 2023 04:10
… of the spurious results either cause they're not there in the first place - this should also speed up processing since we don't need to do a jillion searches

Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
…dn't realize - the original zap sample has a duplicate subfinding for some reason and we were removing it from our results through the dedupe process. now it's put back and correctly reflects the original file

Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
Copy link
Contributor

@Amndeep7 Amndeep7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch. Extended the implication from where you found savings with my own commits.

@Amndeep7 Amndeep7 added the ready-to-merge Used by mergify to identify if a PR is ready to merge into master. label May 23, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mergify mergify bot merged commit 106d957 into mitre:master May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Used by mergify to identify if a PR is ready to merge into master.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants