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:
Olly Betts 2007-09-17 20:10:57 +00:00
commit c836c81acb
11 changed files with 46 additions and 45 deletions

View file

@ -35,14 +35,14 @@ namespace std {
%typemap(in) string (char* tempptr) {
if ($input == C_SCHEME_FALSE) {
$1 = std::string();
$1.resize(0);
} else {
if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
"Argument #$argnum is not a string");
}
}
tempptr = SWIG_MakeString($input);
$1 = std::string(tempptr);
$1.assign(tempptr);
if (tempptr) SWIG_free(tempptr);
}
}
@ -51,7 +51,7 @@ namespace std {
char* tempptr) {
if ($input == C_SCHEME_FALSE) {
temp = std::string();
temp.resize(0);
$1 = &temp;
} else {
if (!C_swig_is_string ($input)) {
@ -59,7 +59,7 @@ namespace std {
"Argument #$argnum is not a string");
}
tempptr = SWIG_MakeString($input);
temp = std::string(tempptr);
temp.assign(tempptr);
if (tempptr) SWIG_free(tempptr);
$1 = &temp;
}
@ -79,7 +79,7 @@ namespace std {
%typemap(varin) string {
if ($input == C_SCHEME_FALSE) {
$1 = std::string();
$1.resize(0);
} else {
char *tempptr;
if (!C_swig_is_string ($input)) {
@ -87,7 +87,7 @@ namespace std {
"Argument #$argnum is not a string");
}
tempptr = SWIG_MakeString($input);
$1 = std::string(tempptr);
$1.assign(tempptr);
if (tempptr) SWIG_free(tempptr);
}
}