code optimization
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
```
// org.apache.dubbo.common.utils.CollectionUtils#269
public static Set ofSet(T... values) {
int size = values == null ? 0 : values.length;
if (size < 1) {
return emptySet();
}
float loadFactor = 1f / ((size + 1) * 1.0f);
if (loadFactor > 0.75f) {
loadFactor = 0.75f;
}
Set elements = new LinkedHashSet<>(size, loadFactor);
for (int i = 0; i < size; i++) {
elements.add(values[i]);
}
return unmodifiableSet(elements);
}
```
in this code, loadFactor is never large than o.75f and too small can lead to frequent rehash, so set loadFactor o.75f is ok?
Contributor guide
Assessment
This issue has not been assessed yet.