Source:
<code>public DecoratableResourceMapping(ResourceMapping mapping) throws IOException { super(null); this.mapping = mapping; IProject[] projects = mapping.getProjects(); if(projects == null || projects.length == 0) return; Set<Repository> repositories = new HashSet<Repository>(projects.length); for(IProject prj : projects) { RepositoryMapping repoMapping = RepositoryMapping.getMapping(prj); if(repoMapping == null) continue; IndexDiffData diffData = GitLightweightDecorator.getIndexDiffDataOrNull(prj); if(diffData == null) continue; tracked = true; Repository repository = repoMapping.getRepository(); String repoRelative = makeRepoRelative(repository, prj) + "/"; Set<String> modified = diffData.getModified(); Set<String> conflicting = diffData.getConflicting(); if(containsPrefix(modified, repoRelative)) dirty = true; if(containsPrefix(conflicting, repoRelative)) conflicts = true; repositories.add(repository); } if(repositories.size() == 1) { Repository repository = repositories.iterator().next(); repositoryName = DecoratableResourceHelper .getRepositoryName(repository); branch = DecoratableResourceHelper.getShortBranch(repository); branchStatus = DecoratableResourceHelper .getBranchStatus(repository); } else if(repositories.size() > 1) { repositoryName = MULTIPLE; Set<String> branches = new HashSet<String>(repositories.size()); for (Repository repository : repositories) { branches.add(DecoratableResourceHelper <START> .getShortBranch(repository)); <END> } if (branches.size() == 1) { branch = branches.iterator().next(); } else { branch = MULTIPLE; } } }</code><technical_language>Please add reduce unnecessary calculation: if (branches.size() > 1) break; (Then set capacity of set 2.)</technical_language>

Target:
public DecoratableResourceMapping(ResourceMapping mapping) throws IOException { super(null); this.mapping = mapping; IProject[] projects = mapping.getProjects(); if(projects == null || projects.length == 0) return; Set<Repository> repositories = new HashSet<Repository>(projects.length); for(IProject prj : projects) { RepositoryMapping repoMapping = RepositoryMapping.getMapping(prj); if(repoMapping == null) continue; IndexDiffData diffData = GitLightweightDecorator.getIndexDiffDataOrNull(prj); if(diffData == null) continue; tracked = true; Repository repository = repoMapping.getRepository(); String repoRelative = makeRepoRelative(repository, prj) + "/"; Set<String> modified = diffData.getModified(); Set<String> conflicting = diffData.getConflicting(); if(containsPrefix(modified, repoRelative)) dirty = true; if(containsPrefix(conflicting, repoRelative)) conflicts = true; repositories.add(repository); } if(repositories.size() == 1) { Repository repository = repositories.iterator().next(); repositoryName = DecoratableResourceHelper .getRepositoryName(repository); branch = DecoratableResourceHelper.getShortBranch(repository); branchStatus = DecoratableResourceHelper .getBranchStatus(repository); } else if(repositories.size() > 1) { repositoryName = MULTIPLE; Set<String> branches = new HashSet<String>(2); for (Repository repository : repositories) { branches.add(DecoratableResourceHelper .getShortBranch(repository)); if (branches.size() > 1) break; } if (branches.size() == 1) branch = branches.iterator().next(); else branch = MULTIPLE; } }