Unverified 提交 c4240183 authored 作者: Turbanov Andrey's avatar Turbanov Andrey 提交者: GitHub

cleanup StringUtils.cache

1. No need to call `hashCode` if  `cache=null`
2. Remove redundant `null` comparison. `String.equals` will anyway return `false`
上级 c5652260
......@@ -941,15 +941,13 @@ public class StringUtils {
} else if (s.isEmpty()) {
return "";
}
int hash = s.hashCode();
String[] cache = getCache();
if (cache != null) {
int hash = s.hashCode();
int index = hash & (SysProperties.OBJECT_CACHE_SIZE - 1);
String cached = cache[index];
if (cached != null) {
if (s.equals(cached)) {
return cached;
}
if (s.equals(cached)) {
return cached;
}
cache[index] = s;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论