提交 399be750 编写于 作者: 浅梦2013's avatar 浅梦2013

代码优化

上级 563f3d1d
......@@ -42,7 +42,7 @@ public enum TopicFilterType {
@Override
public boolean match(String topicFilter, String topicName) {
int prefixLen = TopicFilterType.SHARE_QUEUE_PREFIX.length();
if (topicName.startsWith("/")) {
if (startsWith(topicName, '/')) {
prefixLen = prefixLen - 1;
}
return TopicUtil.match(topicFilter.substring(prefixLen), topicName);
......@@ -56,7 +56,7 @@ public enum TopicFilterType {
@Override
public boolean match(String topicFilter, String topicName) {
// 去除前缀 $share/<group-name>/
int prefixLen = TopicFilterType.findShareTopicIndex(topicFilter, topicName.startsWith("/"));
int prefixLen = TopicFilterType.findShareTopicIndex(topicFilter, startsWith(topicName, '/'));
return TopicUtil.match(topicFilter.substring(prefixLen), topicName);
}
};
......@@ -104,4 +104,7 @@ public enum TopicFilterType {
throw new IllegalArgumentException("Share subscription topicFilter: " + topicFilter + " not conform to the $share/<group-name>/xxx");
}
private static boolean startsWith(String text, char ch) {
return ch == text.charAt(0);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册