aboutsummaryrefslogtreecommitdiff
path: root/Lib/java
diff options
context:
space:
mode:
authorBrad Kotsopoulos <brad.kotsopoulos@gmail.com>2019-06-06 19:21:44 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-06-06 19:29:11 +0100
commit55e835e0ae2d67e0a60c8aed998faac7fa039ca4 (patch)
treecd3bfbd3b2d43390e532982c754aacc624691273 /Lib/java
parentc864546b4ab39838d59502a791854dab3817e38b (diff)
downloadswig-55e835e0ae2d67e0a60c8aed998faac7fa039ca4.tar.gz
Java std::vector constructor performance improvement
Reserve before loop of push_back Refactor li_std_vector testcase This is a squash merge of #1552
Diffstat (limited to 'Lib/java')
-rw-r--r--Lib/java/std_vector.i3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i
index 955e20cac..60ee23ebb 100644
--- a/Lib/java/std_vector.i
+++ b/Lib/java/std_vector.i
@@ -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
-