Java std::vector constructor performance improvement

Reserve before loop of push_back
Refactor li_std_vector testcase

This is a squash merge of #1552
This commit is contained in:
Brad Kotsopoulos 2019-06-06 19:21:44 +01:00 committed by William S Fulton
commit 55e835e0ae
3 changed files with 74 additions and 57 deletions

View file

@ -29,6 +29,8 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
%proxycode %{
public $javaclassname($typemap(jstype, CTYPE)[] initialElements) {
this();
reserve(initialElements.length);
for ($typemap(jstype, CTYPE) element : initialElements) {
add(element);
}
@ -181,4 +183,3 @@ namespace std {
%define specialize_std_vector(T)
#warning "specialize_std_vector - specialization for type T no longer needed"
%enddef