You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you can put a length param into this createList method and initialize the collection with length so that the collection will not resize
it will avoid the resize of the collection and save cpu resources
before:
private Collection createList()
throws IOException {
Collection list = null;
if (_type == null)
list = new ArrayList();
else if (!_type.isInterface()) {
try {
list = (Collection) _type.newInstance();
} catch (Exception e) {
}
}
if (list != null) {
} else if (SortedSet.class.isAssignableFrom(_type))
list = new TreeSet();
else if (Set.class.isAssignableFrom(_type))
list = new HashSet();
else if (List.class.isAssignableFrom(_type))
list = new ArrayList();
else if (Collection.class.isAssignableFrom(_type))
list = new ArrayList();
else {
try {
list = (Collection) _type.newInstance();
} catch (Exception e) {
throw new IOExceptionWrapper(e);
}
}
return list;
}
after:
private Collection createList(int length)
throws IOException {
Collection list = null;
if (_type == null)
list = new ArrayList();
else if (!_type.isInterface()) {
try {
list = (Collection) _type.newInstance();
} catch (Exception e) {
}
}
if (list != null) {
} else if (SortedSet.class.isAssignableFrom(_type))
list = new TreeSet(length);
else if (Set.class.isAssignableFrom(_type))
list = new HashSet(length);
else if (List.class.isAssignableFrom(_type))
list = new ArrayList(length);
else if (Collection.class.isAssignableFrom(_type))
list = new ArrayList(length);
else {
try {
list = (Collection) _type.newInstance();
} catch (Exception e) {
throw new IOExceptionWrapper(e);
}
}
return list;
}
The text was updated successfully, but these errors were encountered:
this class: com.alibaba.com.caucho.hessian.io.CollectionDeserializer.class
CollectionDeserializer.readLengthList.createList()
you can put a length param into this createList method and initialize the collection with length so that the collection will not resize
it will avoid the resize of the collection and save cpu resources
before:
after:
The text was updated successfully, but these errors were encountered: