Merge pull request #19 from li-junpeng/main

perf: 优化代码,提高系统性能。
This commit is contained in:
zongzibinbin
2023-06-05 21:52:36 +08:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -128,7 +128,7 @@ public class UserCache {
@Cacheable(cacheNames = "user", key = "'blackList'")
public Map<Integer, Set<String>> getBlackMap() {
Map<Integer, List<Black>> collect = blackDao.list().stream().collect(Collectors.groupingBy(Black::getType));
Map<Integer, Set<String>> result = new HashMap<>();
Map<Integer, Set<String>> result = new HashMap<>(collect.size());
for (Map.Entry<Integer, List<Black>> entry : collect.entrySet()) {
result.put(entry.getKey(), entry.getValue().stream().map(Black::getTarget).collect(Collectors.toSet()));
}