merged sync transactions#575
Open
taynaps wants to merge 4 commits into
Open
Conversation
audax
reviewed
Nov 15, 2016
| return false; | ||
| } | ||
|
|
||
| private int countAllFiles(Boolean allFiles) { |
Member
There was a problem hiding this comment.
The inverse of the parameter would be more readable imho: finishedFiles
audax
reviewed
Nov 15, 2016
| filesList.add(transactionsList.get(0)); | ||
| for (int i = 1; i < transactionsList.size(); i++) { | ||
| for (int j = 0; j < filesList.size(); j++) { | ||
| if (transactionsList.get(i).getDestination().equals(filesList.get(j).getDestination()) && |
Member
There was a problem hiding this comment.
Iterate with a foreach instead.
Also, this probably is a major performance issue since the algorithm is O(n²). A faster algorithm would be for example:
M is a map
foreach transaction:
if (destination, filename) in map: skip
else: M[(destination, filename)] = transaction
return M.size
This uses a pair of destination and filename to filter out duplicates and is O(n). This hash could also be updated outside of the countAllFiles method, whenever a transaction is removed or added. To only count completed transactions, the implementation would be:
countAllFiles().filter{ it.isDone() }.size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#313 sync transactions merged by file path and name