When wrapping C++ code, generate code which uses
std::string::assign(PTR, LEN) rather than assigning std::string(PTR, LEN). Using assign generates more efficient code (tested with GCC 4.1.2). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9936 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ef4ca158de
commit
c836c81acb
11 changed files with 46 additions and 45 deletions
|
|
@ -36,7 +36,7 @@ class string;
|
|||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
$1 = std::string($1_pstr);
|
||||
$1.assign($1_pstr);
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
||||
%typemap(directorout) string
|
||||
|
|
@ -46,7 +46,7 @@ class string;
|
|||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
$result = std::string($1_pstr);
|
||||
$result.assign($1_pstr);
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
||||
%typemap(directorin,descriptor="Ljava/lang/String;") string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue