mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-09-20 04:24:05 +00:00
perf[stream]: stream.toList() replaces collect(Collectors.toList())
This commit is contained in:
1 parent
ac2d01e6fb
commit
ad7e4f3481
17 files changed
+29
-29
No files matched your search
+1
-1
@@ -103,7 +103,7 @@ public class ConsistentHashConsumerLoadBalancer extends AbstractConsumerLoadBala
|
||||
var sessionStringList = getSessionsByModule(module).stream()
|
||||
.map(session -> new Pair<>(session.getConsumerAttribute().toString(), session.getSid()))
|
||||
.sorted((a, b) -> a.getKey().compareTo(b.getKey()))
|
||||
.toList();;
|
||||
.toList();
|
||||
|
||||
var consistentHash = new ConsistentHash<>(sessionStringList, VIRTUAL_NODE_NUMS);
|
||||
var virtualNodeTreeMap = consistentHash.getVirtualNodeTreeMap();
|
||||
|
||||
@@ -108,7 +108,7 @@ public class RegisterVO {
|
||||
.map(it -> it.trim())
|
||||
.map(it -> it.split(StringUtils.HYPHEN))
|
||||
.map(it -> new ProviderModule(new ProtocolModule(Byte.parseByte(it[0]), it[1]), it[2]))
|
||||
.toList();;
|
||||
.toList();
|
||||
return modules;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RegisterVO {
|
||||
.map(it -> it.trim())
|
||||
.map(it -> it.split(StringUtils.HYPHEN))
|
||||
.map(it -> new ConsumerModule(new ProtocolModule(Byte.parseByte(it[0]), it[1]), it[2], it[3]))
|
||||
.toList();;
|
||||
.toList();
|
||||
return modules;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class RegisterVO {
|
||||
builder.append(StringUtils.SPACE).append(StringUtils.VERTICAL_BAR).append(StringUtils.SPACE);
|
||||
var providerModules = providerConfig.getProviders().stream()
|
||||
.map(it -> StringUtils.joinWith(StringUtils.HYPHEN, it.getProtocolModule().getId(), it.getProtocolModule().getName(), it.getProvider()))
|
||||
.toList();;
|
||||
.toList();
|
||||
|
||||
// 服务提供者模块信息列表
|
||||
builder.append(StringUtils.format("provider:[{}]"
|
||||
@@ -168,7 +168,7 @@ public class RegisterVO {
|
||||
|
||||
var consumerModules = consumerConfig.getConsumers().stream()
|
||||
.map(it -> StringUtils.joinWith(StringUtils.HYPHEN, it.getProtocolModule().getId(), it.getProtocolModule().getName(), it.getLoadBalancer(), it.getConsumer()))
|
||||
.toList();;
|
||||
.toList();
|
||||
|
||||
// 服务消费者模块信息列表
|
||||
builder.append(StringUtils.format("consumer:[{}]"
|
||||
|
||||
@@ -596,7 +596,7 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
try {
|
||||
var children = curator.getChildren().forPath(path).stream()
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.toList();;
|
||||
.toList();
|
||||
return children;
|
||||
} catch (Exception e) {
|
||||
logger.error("unknown exception", e);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class HostAndPort {
|
||||
public static String toHostAndPortListStr(Collection<HostAndPort> list) {
|
||||
var urlList = list.stream()
|
||||
.map(it -> it.toHostAndPortStr())
|
||||
.toList();;
|
||||
.toList();
|
||||
return StringUtils.joinWith(StringUtils.COMMA, urlList.toArray());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SimpleCacheTest {
|
||||
var cache = SimpleCache.build(3000, 6000, 100, new Function<List<String>, List<Pair<String, String>>>() {
|
||||
@Override
|
||||
public List<Pair<String, String>> apply(List<String> keyList) {
|
||||
return keyList.stream().map(it -> new Pair<>(it, "new-" + it + "-value")).toList();;
|
||||
return keyList.stream().map(it -> new Pair<>(it, "new-" + it + "-value")).toList();
|
||||
}
|
||||
}, key -> "empty");
|
||||
|
||||
|
||||
Reference in new issue
Block a user