Skip to content

Commit

Permalink
use Set instead of List to eliminate duplicates
Browse files Browse the repository at this point in the history
One use-case is just selecting all requests in Proxy and invoking this
extension from the context menu. However, if several rows had the same
response content, they'd get checked more than once -- even though it
doesn't help the end result in any way. Using a Set removes duplicates
since ObjectId implements a sane .equals() method. A HashSet performs
this rather well, since ObjectId uses the second 32-bit word from the ID
it represents, resulting in a rather uniform distribution.
  • Loading branch information
dnet committed Mar 3, 2020
1 parent f23d8b6 commit e76bae0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Session(Frame owner, File gitDir, IHttpRequestResponse[] messages) {
public void run() {
try {
long start = System.currentTimeMillis();
List<ObjectId> conditions = messagesToConditions(messages);
Iterable<ObjectId> conditions = messagesToConditions(messages);
Set<RevCommit> cs = findCommits(gitDir, conditions, this);
long delta = System.currentTimeMillis() - start;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand Down Expand Up @@ -160,8 +160,8 @@ private File pickGitDir(Frame owner) {
return gitDir;
}

private List<ObjectId> messagesToConditions(IHttpRequestResponse[] messages) throws NoSuchAlgorithmException {
List<ObjectId> conditions = new ArrayList<>(messages.length);
private Iterable<ObjectId> messagesToConditions(IHttpRequestResponse[] messages) throws NoSuchAlgorithmException {
Set<ObjectId> conditions = new HashSet<>(messages.length);
MessageDigest md = MessageDigest.getInstance("SHA");
for (IHttpRequestResponse messageInfo : messages) {
IHttpService hs = messageInfo.getHttpService();
Expand Down

0 comments on commit e76bae0

Please sign in to comment.